Subject: Re: getting rid of nil
From: rpw3@rpw3.org (Rob Warnock)
Date: Tue, 30 Jun 2009 19:59:41 -0500
Newsgroups: comp.lang.lisp
Message-ID: <1sOdndJYEtJgKdfXnZ2dnUVZ_gSdnZ2d@speakeasy.net>
Kenneth Tilton  <kentilton@gmail.com> wrote:
+---------------
| Slobodan Blazeski wrote:
| > Mirko <mirko.vuko...@gmail.com> wrote:
| >> Is there a way to rewrite
| >>> (let ((a nil))
| >>    `(5 6 ,(when a a)))
| >> (5 6 NIL)
| >>
| >> I would like to get rid of the NIL.
...
| > What's the point of this, since a is always nil why don't you just use
| > (5 6) ?
| 
| The example was distilled from a real-world case in which a might not be 
| nil.
+---------------

I actually run into this quite frequently with macros that call
functions that use a SUPPLIED-P arg to distinguish explicit NIL
values from "missing" NIL values in &OPTIONAL and &KEY args.
The ,@(WHEN FOO-P (LIST FOO)) and ,@(WHEN FOO-P (LIST :FOO FOO))
idioms handle this nicly.


-Rob

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