Subject: Re: calling function with default arguments
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 11 Jul 2007 06:09:20 -0500
Newsgroups: comp.lang.lisp
Message-ID: <QsOdnbhKPLP9JwnbnZ2dnUVZ_s3inZ2d@speakeasy.net>
Kent M Pitman  <pitman@nhplace.com> wrote:
+---------------
| No one has taken me up on my challenge, so I'll offer an alternative just
| to lighten up the mood, and to reward anyone who slugged through the above
| minutiae with a bit of fun...
...
|  (defun foo-2 (&key (bar nil bar-p) (baz nil baz-p))
|    (foo-1 (if bar-p :bar :no-bar)
|           (if bar-p  bar :unused)
|           (if baz-p :baz :no-baz)
|           (if baz-p  baz :unused)
|           :allow-other-keys t))
+---------------

Oooh! That's just *evil*! I love it!!

+---------------
| Actually, I suppose if you wanted to REALLY confuse people, you could use 
| 
|  (defun foo-2 (&key (bar nil bar-p) (baz nil baz-p))
|    (foo-1 (if bar-p :bar :allow-other-keys)
|           (if bar-p  bar :unused)
|           (if baz-p :baz :allow-other-keys)
|           (if baz-p  baz :unused)))
+---------------

Even more so!  ;-}  ;-}


-Rob

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