help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: if vs. when vs. and: style question


From: Emanuel Berg
Subject: Re: if vs. when vs. and: style question
Date: Wed, 25 Mar 2015 01:21:32 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Rusi <address@hidden> writes:

> In general weaker is better
> http://www.w3.org/2001/tag/doc/leastPower.html
>
> (when a b) ... (if a b) However (if a b c) ... (when ??)

What do you mean by "weaker"?

`if' can do three arguments, on the other hand it
needs a `progn' to do several forms. `when' comes with
implicit progn but cannot do the three way
if-else if-else branch.

What I can see `if' is more flexible and you can
change things without having to change the outermost
`if', which is practical. Yes, with the use of `not'
and `progn' if necessary, but I don't see a problem
with that.

> Other example:
>
> destructuring-bind is strictly weaker than if/cond
> and so better when usable

What is "destructuring-bind"?

What do you mean by "strictly weaker"? ("Strictly
less" is (a < b) as opposed to (a <= b) which is
"less than or equal".)

If what you mean by "weaker" is some attempt at
a formalization of "you can do less" then I do not
agree that should be preferred by definition.

For example, here

    (1+ 5)  ; 6
    (+ 1 5) ; 6

I'm sure (1+ 5) looks better to some, but think it is
even steven. It depends. The (+ ... ) construct is
very familiar. And there, the "1" can be changed, or
replaced by a variable name.

If you use the most powerful construct, you can stick
to that, everywhere. The code looks uniform and is
fast to edit.

Of course, if you do enough `when' and `unless' and
three-way `if's then it will probably all look uniform
to you pretty soon, as well. Personally I prefer only
`if's but I'm only mildly passionate about it.
For example, if I inherited code I wouldn't change the
`when's and `unless'es.

-- 
underground experts united


reply via email to

[Prev in Thread] Current Thread [Next in Thread]