On Wed, 10 Nov 2004 10:40:59 -0800, Manuel Simoni wrote:
> This doesn't work (UNBOUND-VARIABLE) and the macroexpansion shows why:
>
> (LET ((A::IT (MAKE-WINDOW))) (SET-WINDOW-TITLE IT "bla") A::IT)
>
> Why are the ITs from the backquoted code sections interned in a
> different package than the &body code?
Because when the string "(defmacro aprog1 ...)" is read, the
current package is #:a. So when the lisp reader sees a string token
"it", it effectively does (intern (string-upcase "it") #:a), which
evaluates to the symbol A::IT.
How about the following alternative.
(defmacro aprog1 (&body body)
(if (null body)
`(values)
`(let ((,(intern "IT") ,(first body)))
,@(rest body)
,(intern "IT"))))
which defer the determination of the package in which "IT" is interned
until the macro expansion time.
Hope this helps.
Yuji.