[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
macroexpand inside of macrolet...
Date: 15 Apr 1987 01:59 PDT
From: David Bein <pyramid!bein@hplabs.HP.COM>
I was playing around inside some macrolet code and came across
what seems to a be a problem (if this issue was discussed ages ago
on this mailing list, please pardon me for raising it again).
(MACROLET ((CONS (A B) `(LIST ',A ',B)))
(MACROEXPAND '(CONS 1 2)))
returns (CONS 1 2) and NIL, while
(MACROLET ((CONS (A B) `(LIST ',A ',B)))
#'CONS)
blows up since FUNCTION sees the local macro definition.
You are confusing compile-time environments with runtime environments.
MACROLET works on code. MACROEXPAND works on structure. Unless you can
somehow grab ahold, at runtime, of the environment MACROLET has created
and pass that environment to MACROEXPAND you won't get what you are
looking for. How about
(MACROEXPAND-all '(MACROLET ((CONS (A B) `(LIST ',A ',B)))
(CONS 1 2)))
=> (MACROLET ((CONS (A B) `(LIST ',A ',B)))
(LIST '1 '2))
where MACROEXPAND-all (not in CL) does a macroexpanding code walk.