[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Macro problem



In article <9211272045.AA19464@mipsmath.math.uqam.ca> cartier@math.uqam.ca (Guillaume Cartier) writes:

   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!!!) ?

Use MACROLET and SYMBOL-MACROLET.

   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*
     ...)

I'm not sure what *current-macro-foo* specifies, but here's an idea:

(defmacro macro-bar (&body)
  (expand-bar-default))

(defmacro macro-foo (name &body)
  `(macrolet ((macro-bar (&body) (expand-bar-using-name ,name body)))
     ,@body))

   Any positive answer will greatly warm my confidence
   to the new ANSI standard! :-)

Hope this counts.

--
Tim Moore                    moore@cs.utah.edu {bellcore,hplabs}!utah-cs!moore
"Wind in my hair - Shifting and drifting - Mechanical music - Adrenaline surge"
	- Rush