From: Andrew Cooke
Subject: Fully expanding a form containing macros
Date: 
Message-ID: <87hns3$a8v$1@nnrp1.deja.com>
Hi,

How do I fully expand a form that contains embedded macros?  Macroexpand
only guarantees that the form is no longer a macro form (first element a
macro name or something about symbol macros that doesn't affect me).

Do I need to walk the code calling macroexpand myself?  Is this not
possible in general because macro expansion can depend on the runtime
environment (ie with different parameters different macros in the
same code might be expanded at different times)?  Is there code that
does some kind of "default expansion"?

Thanks,
Andrew

PS.  If an example makes things clearer - I have code that defines
circuits.  It allows something like "macro" circuits to be defined - the
form that defines one of these circuits is a macro that generates a
macro named after the macro circuit.  When the macro circuit is then
referenced, it expands out into code that calls the individual
components.  This makes describing circuits nice and simple, and the
code is automatically expanded to the component level when the circuit
is "run".  But I now want to analyse the circuit at the component level
and I can't find out how to get Lisp to do the expansion it does when
the code is executed.


Sent via Deja.com http://www.deja.com/
Before you buy.

From: Fernando Mato Mira
Subject: Re: Fully expanding a form containing macros
Date: 
Message-ID: <389C63B0.AF92E216@iname.com>
Andrew Cooke wrote:

> Do I need to walk the code calling macroexpand myself?  Is this not

Your "myself" is ambiguous, so just in case:

http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/codewalk/0.html
From: Andrew Cooke
Subject: Re: Fully expanding a form containing macros
Date: 
Message-ID: <87ibfm$nm3$1@nnrp1.deja.com>
In article <·················@iname.com>,
  Fernando Mato Mira <········@iname.com> wrote:
> Andrew Cooke wrote:
> > Do I need to walk the code calling macroexpand myself?  Is this not
> Your "myself" is ambiguous, so just in case:
http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/cod
ewalk/0.html

When I first started using Lisp a few months ago (yikes - maybe 6) I
remember looking at that code while wandering around the repository and
thinking "what on earth is that for?"....  :-)

Thanks,
Andrew


Sent via Deja.com http://www.deja.com/
Before you buy.
From: Rainer Joswig
Subject: Re: Fully expanding a form containing macros
Date: 
Message-ID: <rainer.joswig-34EA12.20324905022000@news.is-europe.net>
In article <············@nnrp1.deja.com>, Andrew Cooke 
<······@andrewcooke.free-online.co.uk> wrote:

> Hi,
> 
> How do I fully expand a form that contains embedded macros?

Several Lisp systems have their own solution for that.

On a Symbolics do m-sh-M (Macro Expand Expression All)
or call something like (SI:MEXP-EXPAND-FORM ... :ALL-LEVELS T ...)

LWW has it somewhere in an editor menu. And so on...

Rainer Joswig, ISION Internet AG, Harburger Schlossstra�e 1, 
21079 Hamburg, Germany, Tel: +49 40 77175 226
Email: ·············@ision.de , WWW: http://www.ision.de/