>>>"MS" == Michael Sperber schrieb am 24 Aug 1998
11:14:43 +0200:
MS> Thus, in your example,
MS> (setq bar 23)
MS> [if done in fresh CL session]
MS> creates a binding which associates 23 with BAR, and:
MS> (setq bar 57)
MS> modifies the binding created previously.
I knew that already, thanks ;-)
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]
But exactly this behaviour is what you get when you use
(defmacro foo () bar) instead of (defmacro foo () 'bar):
USER(2): (setq bar 23)
23
USER(9): (defmacro foo () bar)
FOO
USER(10): (foo)
23
USER(11): (let ((bar 42)) (foo))
23
USER(12): (setq bar 57)
57
USER(13): (let ((bar 42)) (foo))
57
USER(14):
MS> Note that this is exactly what actually *would* happen if you
MS> wrote: (defun foo () bar) instead of the defmacro.
Yes. And that's why I was so surprised that you would want it
otherwise (which I now see you don't).
My point: yes, one can do what you want to do, also with Common
Lisp. Your point (to which I agree): things can get somewhat hairy
underway.
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