From: Denis Mashkevich
Subject: macroexpansion within lambda forms
Date: 
Message-ID: <9cca45d2.0402150839.1a134a9@posting.google.com>
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

?

From: Paul F. Dietz
Subject: Re: macroexpansion within lambda forms
Date: 
Message-ID: <bKudnflzhPliP7LdRVn-gQ@dls.net>
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
From: Pascal Costanza
Subject: Re: macroexpansion within lambda forms
Date: 
Message-ID: <c0o8rp$r3s$1@newsreader2.netcologne.de>
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."