Re: lambda-returning defmacro, capture
- From: "Andreas Thiele" <noreader@xxxxxxxxxx>
- Date: Wed, 13 Dec 2006 13:09:27 +0100
<to9sn2r02@xxxxxxxxxxxxxx> schrieb im Newsbeitrag news:1166009959.022674.224070@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi, I'm trying to write a macro that (essentially) wraps a lambda ()
around an arbitrary body (it does more than that, but I'm omitting
non-essentials). However,
[2]> (defparameter fff 10)
FFF
[10]> (defmacro mac1 (&rest body) `(lambda () . ,body))
MAC1
[11]> (funcall (let ((fff 11)) (mac1 fff)))
10
(I wanted 11)
Why and what to do? The purpose of the macro is to save typing, in case
you're going to ask.
-- Dan
Hi Dan,
did you try the following?
CL-USER 32 > (funcall (let ((fff 11)) (lambda () fff)))
10
I think defparameter makes fff dynamic, so the lambda catches the dynamic variable fff. See:
CL-USER 49 > (let ((fff 11)) (funcall (mac1 fff)))
11
My two cent :))
Andreas
.
- Prev by Date: Re: Common Lisp from a Unix perspective - barriers to using CL
- Next by Date: Re: lambda-returning defmacro, capture
- Previous by thread: generator and conditions (from the python flame war)
- Next by thread: Re: lambda-returning defmacro, capture
- Index(es):