>>>"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
Isn't this meant to mean to refer to the current binding of bar, which
in this case happens to be 23 ?
MS>(defun baz () (foo)) ; this therefore expands to (defun baz () 23)
MS>(baz) => 23 ; indeed
MS>(setq baz 42) ; the definition of FOO is unchanged
(I guess you mean bar, not baz). You are right, the definition of FOO
is unchanged, it still refers to the current binding of bar - which
now happens to be 42.
MS>(foo) => 23 ; presto
Hence, (foo) should give 42.
USER(29): (setq gee 23)
23
USER(30): (let ((gee 42)) (defmacro fun () gee))
FUN
USER(31): (fun)
42
USER(32): gee
23
USER(37): (let ((gee 42))
(defmacro fun2 () gee)
(setq gee 57)
(fun2))
57
MS> I have to admit, though, that this thread is furthering my
MS> conviction that using CL macros right is something fairly
MS> difficult :-)
Didn't I say this right from the start ? ;-)
However, it also furthers my conviction that refering to non-special,
non-local variables should best be avoided (this applies of course to
CL-macros. But I am still not convinced that this is a useful
construct in general, anyway. Disclaimer: YMMV).
Holger
--
---
http://www.coling.uni-freiburg.de/~schauer ---
">grep schauer passwd
schauer:x:1075:1075:Holger Schauer,
2790:/home/schauer:/usr/bin/xemacs"
"Das ist nur eine Shell. Bedenklich
waere, wenn Dein LILO /vmunix.el bootet."
-- Kristian und Holger in de.comp.os.linux.misc