Subject: Re: Code walker library for CL
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 26 Mar 2009 20:22:18 -0500
Newsgroups: comp.lang.lisp
Message-ID: <0eKdnVp6xp_Xt1HUnZ2dnUVZ_tPinZ2d@speakeasy.net>
Pascal J. Bourguignon <pjb@informatimago.com> wrote:
+---------------
| Indeed, implementations often provide one. 
| Eg. #+clisp ext:expand-form
+---------------

+cmu walker:walk-form

Signature:

    WALKER:WALK-FORM (form &optional environment walk-function)

where the default walk-function is:

    (lambda (subform context env)
      (declare (ignore context env))
      subform)))

There's also WALKER:MACROEXPAND-ALL (a wrapper around WALK-FORM,
which binds special variable WALKER:WALK-FORM-EXPAND-MACROS-P to T),
which is useful when you want to see the expansions of things
inside special forms, e.g.:

    > (macroexpand
	'(let ((x 1))
	   (incf x)))

    (LET ((X 1))
      (INCF X))
    NIL
    > (walker:macroexpand-all
	'(let ((x 1))
	   (incf x)))

    (LET ((X 1))
      (LET* ((#1=#:G1589 1) (#2=#:G1588 (+ X #1#)))
	  (SETQ X #2#)))
    > 


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607