From: ···@livelogix.com
Subject: Find free variables in macro arguments
Date: 
Message-ID: <1124423350.864282.195440@g47g2000cwa.googlegroups.com>
Hi,

In a macro, how would I go about obtaining a list of the variables
which are free in the macro argument s-exprs?

I figure I need to use some kind of s-expr walker that knows about the
variable binding operators. The problem is, it wont know about
name-binding macros.

The only solution I can think of is to (macroexpand) the arguments
myself, and then run the walker. Is that bad form? I guess, to avoided
duplicating the work, the macro should then return this fully expanded
code. I can't see any problem with that right now, but it feels a bit
ify.

So I guess there are two questions:

 - What's the best way to find the free variables in an s-expr?

 - Is it bad form for a macro to (macroexpand) its own arguments,
rather than letting the macro engine do this?

Thanks

Tom.
From: Barry Margolin
Subject: Re: Find free variables in macro arguments
Date: 
Message-ID: <barmar-CE7D1C.01292119082005@comcast.dca.giganews.com>
In article <························@g47g2000cwa.googlegroups.com>,
 ····@livelogix.com" <···@livelogix.com> wrote:

> So I guess there are two questions:
> 
>  - What's the best way to find the free variables in an s-expr?

Use a code walker.

>  - Is it bad form for a macro to (macroexpand) its own arguments,
> rather than letting the macro engine do this?

Expanding macros is part of what code walkers are expected to do.  It's 
the only way they can possibly do the right thing with macros.  The 
MACROEXPAND function is the interface to the "macro engine" that's 
provided precisely for this purpose.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***