[Rd] access to R parse tree for Lisp-style macros?

Thomas Lumley tlumley at u.washington.edu
Mon Oct 3 16:22:14 CEST 2005


On Mon, 3 Oct 2005, Duncan Murdoch wrote:

> On 10/3/2005 3:25 AM, Andrew Piskorski wrote:
>> R folks, I'm curious about possible support for Lisp-style macros in
>> R.  I'm aware of the "defmacro" support for S-Plus and R discussed
>> here:
>>
>>   http://www.biostat.wustl.edu/archives/html/s-news/2002-10/msg00064.html
>>
>> but that's really just a syntactic short-cut to the run-time use of
>> substitute() and eval(), which you could manually put into a function
>> yourself if you cared too.  (AKA, not at all equivalent to Lisp
>> macros.)

Well, yes and no.  It is a syntactic shortcut using functions, but what it 
does is manipulate and then evaluate pieces of parse tree.  It doesn't 
have the efficiency under compilation that real macros would, but we don't 
have compilation.  It doesn't have gensyms, but again, R fails to support 
these in a fairly fundamental way, so they have to be faked using 
variables with weird random names.

I have a long-term plan to add real macros, but not until after Luke 
Tierney's byte-code compiler is finished.

 	-thomas



More information about the R-devel mailing list