You can use function EXT:EXPAND-FORM to expand all the macros,
SYMBOL-MACROs, etc, in a single form:
(EXT:EXPAND-FORM'(macrolet ((bar (x) `(print ,x))) (macrolet ((baz (x) `(bar ,x))) (symbol-macrolet ((z 3)) (baz z))))) ⇒(locally (print 3)); the expansion ⇒; indicator: some expansion has actually been doneT
This is sometimes called a “code walker”,
except that a code walker would probably leave the MACROLET and
SYMBOL-MACROLET forms intact and just do the expansion.
Function EXT:EXPAND-FORM is the exported part of the
CLISP interpreter (AKA EVAL), so it expands forms by assuming the
EVAL-WHEN situation :EXECUTE and is therefore
unsuitable for forms that may later be passed to the compiler:
(EXT:EXPAND-FORM'(EVAL-WHEN(:COMPILE-TOPLEVEL) (foo))) ⇒; ⇒NIL(TEXT:EXPAND-FORM'(EVAL-WHEN(:LOAD-TOPLEVEL) (foo))) ⇒; ⇒NILT
| These notes document CLISP version 2.49 | Last modified: 2010-07-07 |