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-MACRO`s, 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.45 | Last modified: 2008-05-14

Enter your search termsSubmit search form
Webclisp.cons.orgclisp.podval.orgwww.lisp.org

Prev | Up | Next
31.12. Customizing CLISP behavior | Home | Chapter 32. Platform Specific Extensions