On 5/29/06, Ryan Culpepper <ryan_sml at yahoo.com> wrote:
> Is your goal to treat this one macro as though it were a new
> primitive syntactic form? That is, you want to expand all macros,
> both outside of occurrences of "stop" and within contexts inside of
> "stop" forms? If so, that's a much more difficult problem than I
> thought you were describing the first time I read this.
Yes, that's basically my goal.
> Can you provide a little more information about what you need this
> for? Perhaps there is another way to accomplish your goal.
What I'm actually trying to do is static optimization/compilation of
FrTime programs. My current problem stems from the if statement. In
FrTime, if is a macro that expands into a relatively complicated
expression. I need to be able to prevent that expansion in some
contexts, and replace the FrTime if with a kernel if.
There are two ways that I can see to do this. My first approach was
to use local-expand, as I explained before. My second approach was to
do a global search-and-replace before calling expand. This second
approach actually works *too* well -- I can no longer tell the
difference between an if that was inserted by the search-and-replace,
versus one that was inserted by the expansion of some other macro.
The two cases have very different semantics, so it is important to
distinguish between them. An additional problem with the second
approach is that in some cases I need to have access to the original
unmodified source -- which requires doing another search and replace
to undo my previous changes.
I'm currently looking into using the second approach, and tagging the
newly inserted ifs somehow so that I can distinguish them from ifs
that were inserted by other means. I'm unhappy with this approach
because 1) it requires two hacks (tagging the inserted forms and
reverting the replacements), and 2) it seems like local-expand would
be a more elegant approach if I could get it to work.
I also asked because I don't like working around errors I don't understand.