Re: gensym in macro definition



On Thu, 31 Aug 2006 04:55:17 +0000, Stephen Compall wrote:

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.

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.

(defmacro n-of2 (n expression)
`(loop repeat ,n
collect ,expression))

--
"Don't worry about people stealing your ideas. If your ideas are any
good, you'll have to ram them down people's throats."
-- Howard Aiken

.