Re: lambda-returning defmacro, capture




<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

.