[gambit-list] Any direction on implement a arc style macro?

Per Eckerdal per.eckerdal at gmail.com
Sat May 14 18:22:05 EDT 2011

Unless you are willing to do highly sophisticated static analysis, you will have to implement a new eval to do that. For a tutorial and some example code on how to do that, check out http://matt.might.net/articles/metacircular-evaluation-and-first-class-run-time-macros/

That could be complemented by hooking the eval function to the ##expand-source REPL hook, which should basically be a function that takes an expression and returns another (processed) one. That would make it possible to use the language with arc style macros from the REPL.

Black hole uses these hooks, see for instance https://github.com/pereckerdal/blackhole/blob/master/build.scm for one example of usage. (In essence, it set!s the hook and its compilation counterpart c#expand-source to black hole's own macro expansion function, taking care of the fact that they sometimes get gambit's internal source code location annotation objects as input)

Per Eckerdal
On Friday, 13 May 2011 at 08:51, Meng Zhang wrote: 
> Hi everyone,
> I'm trying to make a macro can be used as a variable on runtime.In arc a macro is simply a function tagged with 'mac, which is #('tagged 'mac function). so it can be referenced as a variable.
>  Is there any hook can be set to be called when applying a variable or I have to implement a new eval? Any directions?
> Thank you!
> -- 
> Meng Zhang
> Sent with Sparrow
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20110515/b260ea22/attachment.htm>

More information about the Gambit-list mailing list