Subject: Re: Lisp Syntax - functions versus data
From: rpw3@rpw3.org (Rob Warnock)
Date: Tue, 27 Feb 2007 22:40:05 -0600
Newsgroups: comp.lang.lisp
Message-ID: <acmdnVoomp44mnjYnZ2dnUVZ_hGdnZ2d@speakeasy.net>
Vassil Nikolov  <vnikolov+usenet@pobox.com> wrote:
+---------------
| Andre Thieme <address.good.until.2007.may.12@justmail.de> said:
| | say:
| | (when list
| |    (code))
| | An IF that returns an empty list can be replaced with either
| | WHEN or with UNLESS.
| 
|   The usual approach is to use WHEN or UNLESS when evaluating for side
|   effect; if the returned value will be used, IF is in order with both
|   a "then" and an "else" expression.
+---------------

Yes, but... even that rule has its exceptions. After all, the value
of WHEN when the test is false *is* well-defined in the CLHS to be NIL,
and I find that (for example) doing conditional splicing of optional
forms into backquoted macro bodies looks better done this way:

    ,@(when test (list form1 form2 ...))

or even this way if there's just one form
[though I still personally prefer using the WHEN]:

    ,@(and test (list form))

rather than this way:

    ,@(if test (list form1 form2 ...) nil)

YMMV, of course.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607