[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
- if vs. when vs. and: style question, Marcin Borkowski, 2015/03/23
- RE: if vs. when vs. and: style question, Drew Adams, 2015/03/23
- Re: if vs. when vs. and: style question, Pascal J. Bourguignon, 2015/03/23
- Message not available
- Re: if vs. when vs. and: style question,
Emanuel Berg <=
- Re: if vs. when vs. and: style question, Rusi, 2015/03/24
- Re: if vs. when vs. and: style question, Emanuel Berg, 2015/03/24
- Re: if vs. when vs. and: style question, Pascal J. Bourguignon, 2015/03/24
- Re: if vs. when vs. and: style question, Emanuel Berg, 2015/03/24
- Re: if vs. when vs. and: style question, Rusi, 2015/03/24
- Re: if vs. when vs. and: style question, Pascal J. Bourguignon, 2015/03/25
- Re: if vs. when vs. and: style question, Rusi, 2015/03/25
- Re: if vs. when vs. and: style question, Stefan Monnier, 2015/03/25
- Re: if vs. when vs. and: style question now Unicode, Dan Espen, 2015/03/25
- Re: if vs. when vs. and: style question now Unicode, Rusi, 2015/03/25