[Rd] :: and ::: as .Primitives?

Duncan Murdoch murdoch.duncan at gmail.com
Fri Jan 23 21:59:29 CET 2015


On 22/01/2015 4:06 PM, Peter Haverty wrote:
> Hi all,
> 
> I use Luke's "::" hoisting trick often. I think it would be fantastic
> if the JIT just did that for you.
> 
> The main trouble, for me, is in code I don't own.  When common
> Bioconductor packages are loaded many, many base functions are saddled
> with this substantial dispatch and "::" overhead.
> 
> While we have the hood up, the parser could help out a bit here too.
> It already has special cases for "::" and ":::". Currently you get the
> symbols "pkg" and "name" and have to go fishing in the calling
> environment for the associated values.  

I don't think the parser should do this, but it does seem like a
reasonable optimization for the compiler to do.

It would be nice to have the
> parser or JIT rewrite base::match as doubleColon("base","match") or
> directly provide the symbols "base" and "match" to the subsequent
> code.

Currently the parser provides the expression `::`(base, match), and the
`::` function converts those symbols to character strings "base" and
"match".  While the parser could have saved it some work by giving the
expression `::`("base", "match"), I think it's a bad idea to start
messing with things that way.  After all, a user could have defined
their own `::` function, and they should get what they typed.

Duncan Murdoch



More information about the R-devel mailing list