[plt-scheme] Is there a way to "apply" a macro?
I have to figure out the pieces at run-time. The macro is rather
involved and was written by someone smarter than I, so I was hoping to
avoid having to figure out exactly how it's doing what it's doing and
just trust it to do the right thing. Serves me right for being lazy.
Thanks!
Todd
On Sun, Apr 11, 2010 at 5:07 PM, Carl Eastlund <carl.eastlund at gmail.com> wrote:
> On Sun, Apr 11, 2010 at 5:01 PM, Todd O'Bryan <toddobryan at gmail.com> wrote:
>> OK, I know there isn't, since macros match before the code has a
>> chance to run, but here's what I need to do:
>>
>> I'm using someone else's very nice macro that has the form
>>
>> (macro-name expr [literal1 val1] [literal2 val2] ...)
>>
>> The problem is that I have to build up the "expr [literal1 val1]
>> [literal2 val2] ..." programmatically and the macro is pretty
>> complicated.
>>
>> So, how do I put together all the parts after the macro name and then
>> get the result as if they'd gone through macro expansion?
>>
>> Todd
>
> What do you mean by "have to build up the [body] programmatically"?
> Do you mean you have to do it at run-time? Or do you mean you need
> more than just pattern matching to build it? If the former,
> presumably it would be just as easy to write the code directly without
> the macro as it would be to compute the macro, expand it, and run it.
> If the latter, there's no reason you can't build syntax
> programmatically within a macro based on syntax-case or syntax-parse.
>
> --Carl
>