Re: Order of macroexpansion
- From: pjb@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon)
- Date: Thu, 31 Jan 2008 15:06:15 +0100
Peter Hildebrandt <peter.hildebrandt@xxxxxxxxx> writes:
Rainer,
thanks for the quick response.
Outer is expanded. It returns a new form.
Whatever 'outer' returns will then be evaluated
as usual. Rember, the expansion of outer might
or might not have the 'inner' form.
Okay, so that means, if I create a binding in outer during expansion
time (as in my example below), this binding will be available at the
expansion of inner, right?
With the "unhygienic" status, yes.
(let (store)
(defmacro outer (val &body body) (setf store val) `(progn ,@body))
(defmacro inner (expr) `(,expr ,store)))
Beware that closure don't travel nicely thru fasl files. IIRC, it's
implementation dependent whether STORE is still shared between the
(macro-function 'outer) and (macro-function 'inner) closures after
LOAD.
So if I specify that inner is only to be used inside some surrounding
"outer", inner can be implemented this way, and I am on the safe side?
For this you should rather use macrolet:
(defmacro outer (&body body)
"
In body, you can use (INNER stuff) to do something.
"
`(let ((your-binding))
(macrolet ((inner (arg) `(progn (do-something-with your-binding) (and-your ,arg))))
,@body)))
(outer
(hi)
(inner lo)
(yo))
--
__Pascal Bourguignon__
.
- References:
- Order of macroexpansion
- From: Peter Hildebrandt
- Re: Order of macroexpansion
- From: Rainer Joswig
- Re: Order of macroexpansion
- From: Peter Hildebrandt
- Order of macroexpansion
- Prev by Date: Re: Order of macroexpansion
- Next by Date: Re: Security
- Previous by thread: Re: Order of macroexpansion
- Next by thread: Re: Order of macroexpansion
- Index(es):
Relevant Pages
|
|