If I do this:
(loop for (a b) in list-of-a-b-pairs
do (print a))
then my compiler complains about "unused variable b".
I can't figure out where to put the appropriate (declare (ignore b))
statement.
Any help appreciated, --Hans
In article <················@starbase> ······@starbase.mitre.org (Hans Tallis) writes:
>If I do this:
>
> (loop for (a b) in list-of-a-b-pairs
> do (print a))
>
>then my compiler complains about "unused variable b".
>I can't figure out where to put the appropriate (declare (ignore b))
>statement.
LOOP's destructuring ignores extra values when there are no variables to go
with them, so you can write:
(loop for (a) in list-of-a-b-pairs
do (print a))
It also allows NIL to be used as a placeholder, so you could write:
(loop for (a nil) in list-of-a-b-pairs
do (print a))
This has some self-documentation effect (it suggests that each element of
LIST-OF-A-B-PAIRS is a two-list); however, the real benefit of this use of
NIL is when it's an intermediate variable, as in the example at the top of
p.745 of CLtL2.
Note that this is different from DESTRUCTURING-BIND and DEFMACRO. Those
support IGNORE declarations, so they don't need this feature.
--
Barry Margolin
System Manager, Thinking Machines Corp.
······@think.com {uunet,harvard}!think!barmar