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: Tue, 24 Mar 2015 03:28:39 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

"Pascal J. Bourguignon" <pjb@informatimago.com>
writes:

> In general, WHEN is better than IF.
>
> Also, (unless (e1) (e2)) is better than (if (not (e1))
> (e2)).
>
> Notably, WHEN and UNLESS have an implicit progn:

"In general", you say. Is there any other advantage
save for not having to do the explicit `progn' and/or
`not'?

For almost no one is LISP the first language learned.
By the time most people stumble upon LISP they have
already written on zillions of if clauses. So I think
`if' is clearer and the explicit `progn' and `not'
doesn't bother me, but both (all) ways are good.

> So you can typically have functions such as:
>
>   (defun find-thingy (name) (or
> (find-thingy-in-whatcha name) (find-thingy-in-macall
> name) (find-thingy-in-it name) (error "not found")))
>
> which is much more concise and clear than ...

But is it clearer than

    (defun look-here () "here")

    (cond
     ((look-here))
     ((look-there))
     (t (message "Not found")))

as well? I always thought of `cond' and `if' as
identical save for syntax.

-- 
underground experts united


reply via email to

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