Re: gensym in macro definition



Guybrush Threepwood wrote:
(defmacro n-of (n expression)
(let ((i (gensym)))
`(loop for ,i from 1 to ,n
collect ,expression)))

I wonder if the gensym is really necessary. According to the rules for
detecting variable capture in Graham's On Lisp I think it is. Am I right?

It is necessary for the code you have output. For extra fun find the
loop-clause that will let LOOP do this without an explicit variable.

--
Stephen Compall
http://scompall.nocandysw.com/blog
.