At 09:09 AM 8/28/98 +0200, Michael Sperber [Mr. Preprocessor] wrote:
>>>>> "Craig" == Craig Lanning
<CraigL(a)internetx.net> writes:
Craig> At 02:20 PM 8/26/98 +0200, Michael Sperber [Mr. Preprocessor] wrote:
>>>>>>> "Holger" == Holger Schauer
<schauer(a)coling.uni-freiburg.de> writes:
>>
>>>>>>> "MS" == Michael Sperber schrieb am 26 Aug 1998
12:14:52 +0200:
>>
MS> Can you explain to me why the above should lead to a different
MS> result? CLISP's output is exactly what I expected it to be:
>>
MS> (setq bar 23)
MS> (defmacro foo () bar) ; this means (foo) expands to the value of BAR
>>
Holger> Isn't this meant to mean to refer to the current binding of bar,
> which
Holger> in this case happens to be 23 ?
>>
>> What do you mean by "current"? BAR is supposed to refer to the
>> binding introduced by (setq bar 23), which is the lexically enclosing
>> one. The question is: when is the binding resolved?
Craig> At macro expansion time.
:-)
This doesn't clarify the relationship in time between binding
resolution and the binding mutations in the code.
This example is too simplistic. (The self quoting thing again.)
CL-USER 19 > (load "E:/sample.lsp")
; Loading text file E:\sample.lsp
(setq foo 'bar) => BAR
Warning: Syntactic warning for form FOO:
FOO assumed special.
(defmacro baz () foo) => BAZ
(baz) => <debugger with BAR is unbound>
(setq bar 42) => 42
(baz) => 42
(let ((bar 23)) (baz)) => 23
#P"E:/sample.lsp"
CL macros use quoting to move evaluation from the macro definition
lexical environment into the macro use lexical environment.
Craig Lanning
E-Mail: CraigL(a)InternetX.net