31.13. Code Walker
Prev Chapter 31. Platform Independent Extensions Next

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 expansionT  	; 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.49Last modified: 2010年07月07日




31.12. Customizing CLISP behavior Home Chapter 32. Platform Specific Extensions

AltStyle によって変換されたページ (->オリジナル) /