Kaz Kylheku <kkylheku@gmail.com> wrote:
+---------------
| Pascal Bourguignon wrote:
| > "Kaz Kylheku" <kkylheku@gmail.com> writes:
| > > This should be allowed:
| > > (destructuring-bind (() a b c) (list 1 2 3 4))
| > > The 1 in the data is matched by () which is the atom NIL, of course.
| > > Atom against atom is valid!
| > > Wouldn't you know it, this fails on CLISP! Should it?
| >
| > IMO, yes.
|
| Why?
+---------------
Maybe because LISTP trumps SYMBOLP in the patterns?
CMUCL also barfs on that example, *not* because of the NIL in the
template, but because:
Error while parsing arguments to DESTRUCTURING-BIND in "Top-Level Form":
Bogus sublist:
1
to satisfy lambda-list:
()
However, if you feed CMUCL *this* it works just fine:
> (destructuring-bind (() a b c) (list () 2 3 4) (+ a b c))
9
>
Note: An old version of CLISP (2.29) also barfs on the latter,
with the message:
*** - LET*: NIL is a constant, cannot be bound
I don't know what current versions give.
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607