gensym in macro definition



I'm making exercises on macros and this is one I found in the archives of
the group.

;;; Define a macro n-of that takes a number n and an expression, and
;;; returns a list of n successive values returned by the expression

(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?

(If anyone can state some fun macro exercises, please do so.)

--
"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

.



Relevant Pages

  • Re: assembler question (strong typing)
    ... It's no more an imposition than any other option that someone may ... Nor for that matter have I called its lack a deficiency. ... I disagree that macros are the answer. ... Search the archives at http://bama.ua.edu/archives/ibm-main.html ...
    (bit.listserv.ibm-main)
  • RE: assembler question (strong typing)
    ... Where did John Ehrman write that? ... I disagree that macros are the answer. ... One's own macros may do what one wants them to do witrhout imposing one's ... Search the archives at http://bama.ua.edu/archives/ibm-main.html ...
    (bit.listserv.ibm-main)
  • Re: A List of Macros
    ... Search the archives: ... using the term "list of macros" and you'll find several ways, depending ...
    (microsoft.public.excel)