gensym question
Posted: Fri Sep 18, 2009 7:19 am
Hi all,
I'm learning Lisp by reading Practical Common Lisp. I have a question regarding gensym.
The book presents on chapter 9 the macro with-gensyms:
It's fine. I understand how it works. I would like to know if there's any drawback in reimplementing it like this:
I think it's a little more efficient as gensym only gets called during the macroexpansion, not at runtime. However, being at a very early stage of learning Lisp (10 days), I'm not sure if it is dangerous to call gensym like this for some reason.
Thanks in advance.
I'm learning Lisp by reading Practical Common Lisp. I have a question regarding gensym.
The book presents on chapter 9 the macro with-gensyms:
Code: Select all
(defmacro with-gensyms ((&rest names) &body body)
`(let ,(mapcar (lambda (x) `(,x (gensym))) names) ,@body))
Code: Select all
(defmacro with-gensyms ((&rest names) &body body)
`(let ,(mapcar (lambda (x) `(,x ',(gensym))) names) ,@body))
Thanks in advance.