[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Macros; lexcial scope
> Wait a minute, you are using your own definition of "correct." I would
> say that T's behavior in both cases is incorrect (I designed T macros,
> so I get to say).
Sorry, I meant "correct" as per the discussion, i.e., "correct if macros are
defined by evaluating their bodies in the lexical environment of the
define-macro". I should have provided more of the context.
> You are also wrong about what happens; the behavior
> you describe is true of interpreted code, but not for compiled code. If
> you compile the file first, you'll get "X unbound variable" for the
> first case, and "M unbound variable" in the second.
Just to make sure I understand you, since "X unbound variable" is the desired
behavior for the first case, that means that the macro body isn't evaluated
(at compile-time) in the lexical environment of the define-macro. So the
compile-time environment of the macro isn't the lexical environment of the
define-macro. I realize that one might want this on occasion, but I guess I
don't understand why this shouldn't be so by default for a vanilla definition
in a vanilla file.
In the second case, M is indeed unbound inside the LET, but the macro M gets
defined at top-level: it returns 2 when you type (M), which seems
inconsistent with the "X unbound variable" error in the first case (i.e., it
seems that the lexical environment of the define-macro, the LET, is also its