31.13. Code Walker

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
⇒ T indicator: some expansion has actually been done

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.

Warning

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 ;
⇒ T
(EXT:EXPAND-FORM '(EVAL-WHEN (:LOAD-TOPLEVEL) (foo)))
⇒ NIL ;
⇒ T

These notes document CLISP version 2.49+Last modified: 2012-05-04