Re: Nested &REST parameter vs. single named parameter



"Michael J. Forster" <mike@xxxxxxxxxxxxxx> writes:

> Aside from the interaction of &REST parameters with &KEY
> parameters, this choice does seem to be a matter of taste.
> However, to me, the difference is further blurred when
> comparing the implementations of WITH-GENSYMS by Paul
> Graham [3]
>
> (defmacro with-gensyms (syms &body body)
> `(let ,(mapcar #'(lambda (s)
> `(,s (gensym)))
> syms)
> ,@body))
>
> and Peter Seibel [4]
>
> (defmacro with-gensysms ((&rest names) &body body)
> `(let ,(loop for n in names collect `(,n (gensysm)))
> ,@body))
>
> Both require me to pass the the arguments in a list
>
> (with-gensyms (foo bar baz)
> ...)
>
> Is there any reason to write ((&rest names) ...) instead of
> (syms ...) in this example?

I use ((&rest names) ...) because that gives me a bit of error
checking for free--if you try to write:

(with-gensyms 10 (stuff))

the compiler will complain if you use my version because 10 is not a
list.

-Peter

--
Peter Seibel * peter@xxxxxxxxxxxxxxx
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp * http://www.gigamonkeys.com/book/
.