Denis Mashkevich wrote:
> Why macroexpand doesn't show expansions within lambda forms?
>
> (defmacro 3+ (a) `(+ ,a 3))
> =>3+
> (macroexpand '(lambda () (3+ 3)))
> =>(FUNCTION (LAMBDA NIL (3+ 3)))
> =>T
>
> although macroexpansion obviously occurs:
> (funcall #'(lambda () (3+ 3)))
> =>6
>
> ?
MACROEXPAND only expands at the top level. It doesn't walk the
form and expand subterms. For that, you need to write a 'code walker'
(that understands the various lisp special forms). Or, better,
grab one from a library somewhere.
Paul
Paul F. Dietz wrote:
> MACROEXPAND only expands at the top level. It doesn't walk the
> form and expand subterms. For that, you need to write a 'code walker'
> (that understands the various lisp special forms). Or, better,
> grab one from a library somewhere.
Some Common Lisps provide MACROEXPAND-ALL for these purposes.
Pascal
--
Tyler: "How's that working out for you?"
Jack: "Great."
Tyler: "Keep it up, then."