gensym in macro definition
- From: Guybrush Threepwood <spambak@xxxxxxxxxxx>
- Date: Thu, 31 Aug 2006 06:18:54 +0200
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
.
- Follow-Ups:
- Re: gensym in macro definition
- From: Kaz Kylheku
- Re: gensym in macro definition
- From: Stephen Compall
- Re: gensym in macro definition
- Prev by Date: Re: Lisp Garbage Collection
- Next by Date: Re: LISP V APL?
- Previous by thread: Lisp Garbage Collection
- Next by thread: Re: gensym in macro definition
- Index(es):
Relevant Pages
|