>>>> "Holger" == Holger Schauer
<schauer(a)coling.uni-freiburg.de> writes:
>>>> "MS" == Michael Sperber schrieb am 24 Aug
1998 11:14:43 +0200:
MS> Your example evaluates BAR at macro-definition time which surely
MS> is not what you intended. (I.e., (foo) expands to 23,
MS> regardless.) What I want is:
MS> (setq 23)
MS> (defmacro foo () 'bar)
MS> (foo) => 23
MS> (let ((bar 42)) (foo)) => 23 [note: CL actually yields 42]
MS> (setq bar 57)
MS> (foo) => 57
MS> (let ((bar 42)) (foo)) => 57 [note: CL actually yields 42]
Holger> But exactly this behaviour is what you get when you use
Holger> (defmacro foo () bar) instead of (defmacro foo () 'bar):
Holger> USER(2): (setq bar 23)
Holger> 23
Holger> USER(9): (defmacro foo () bar)
Holger> FOO
Holger> USER(10): (foo)
Holger> 23
Holger> USER(11): (let ((bar 42)) (foo))
Holger> 23
Holger> USER(12): (setq bar 57)
Holger> 57
Holger> USER(13): (let ((bar 42)) (foo))
Holger> 57
Holger> USER(14):
Another problem with this approach is that it breaks in the following
case:
(setq bar 23)
(defmacro foo () bar)
(defun baz () (foo))
(baz) => 23
(setq bar 42)
(baz) => [still ...] 23
This makes obvious that the macro dereferences the binding too early.
(Namely, at expansion time.)
--
Cheers =8-} Chipsy
Friede, Völkerverständigung und überhaupt blabla