[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Macro problem
- To: info-mcl@cambridge.apple.com (Macintosh Common Lisp)
- Subject: Macro problem
- From: cartier@math.uqam.ca (Guillaume Cartier)
- Date: Fri, 27 Nov 92 15:45:17 -0500
In another message I asked:
Does anyone know if COMPILER-LET will stay
in the new ANSI Common Lisp standard?
Tim Moore replied:
It is not included in the standard.
So, here's why I sent the question in the first place!
Without COMPILER-LET, how can a macro cooperate with another one
that is destined to be embeded into it maybe deeply (without having
to write a complete common lisp code walker!!!) ?
Here is how I do it using COMPILER-LET:
(defvar *current-macro-foo*
nil)
(defmacro MACRO-FOO (name &body body)
`(compiler-let ((*current-macro-foo* ',name))
,@body))
(defmacro MACRO-BAR (&body)
...
expand according to *current-macro-foo*
...)
(defun toto ()
(MACRO-FOO 'hello
...
(MACRO-BAR ...) --> called inside 'hello
(MACRO-FOO 'hi-there
(MACRO-BAR ...)))) --> called inside 'hi-there
Any positive answer will greatly warm my confidence
to the new ANSI standard! :-)
Many thanks to any answer.
*********************************************************************
* Guillaume Cartier (514) 844-5294 (maison) *
* L.A.C.I.M. (514) 987-4290 (bureau) *
* Universite du Quebec a Montreal (514) 987-8477 (telecopieur) *
* Montreal, Quebec, Canada cartier@math.uqam.ca (internet) *
*********************************************************************