On Tue, May 26, 2009 at 6:15 AM, Alex Shinn <[email protected]> wrote: > This isn't actually a correct translation. DEFVAR and > DEFMACRO actually act at the top-level, even when wrapped > inside a LET. If you try it yourself, both a and m are > still defined outside that LET.
Ah, ok. As you see, I have no knowledge of Common Lisp ;-) > A better translation would be > > (let ((a 42)) (macrolet ((m () a)) (m))) > > which indeed will give you the error: > > ... > Compile-time error: > (in macroexpansion of (M)) > (hint: For more precise location, try *BREAK-ON-SIGNALS*.) > The variable A is unbound. > ... > > in CL (checked in SBCL). In Emacs it still works. > Technically CL implementations are allowed, but not > required, to support this. From the CLHS: > > The macro-expansion functions defined by macrolet are > defined in the lexical environment in which the macrolet > form appears. Declarations and macrolet and > symbol-macrolet definitions affect the local macro > definitions in a macrolet, but the consequences are > undefined if the local macro definitions reference any > local variable or function bindings that are visible in > that lexical environment. Understood.
