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

Warnes, Gregory R gregory.r.warnes at pfizer.com
Tue Oct 4 17:35:13 CEST 2005


FWIW, the latest version of the 'gtools' package includes a slightly
enhanced version of Thomas's 'defmacro' function, as well as the 'strmacro'
function that does string-based macro processing.  Feel free to take a look
at them and suggest enhancements (via patches :^)

-Greg


> -----Original Message-----
> From: r-devel-bounces at r-project.org
> [mailto:r-devel-bounces at r-project.org]On Behalf Of Thomas Lumley
> Sent: Monday, October 03, 2005 10:22 AM
> To: Duncan Murdoch
> Cc: r-devel at r-project.org; Andrew Piskorski
> Subject: Re: [Rd] access to R parse tree for Lisp-style macros?
> 
> 
> 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/msg0
0064.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

______________________________________________
R-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

----------------------------------------------------------------------
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}



More information about the R-devel mailing list