[R] how to get a primitive function object

Duncan Murdoch murdoch at stats.uwo.ca
Fri Jan 23 20:50:24 CET 2009


On 1/23/2009 1:47 PM, Yi Zhang wrote:
> On Fri, Jan 23, 2009 at 5:15 AM, Patrick Burns <pburns at pburns.seanet.com> wrote:
>> If I understand properly, you want '<-' to be
>> a generic function, which it currently isn't.
>> There may be a way to fake that (I can't think
>> of any).
>>
>> But I'm wondering if you should rethink what
>> you want.  The only reason that I can think of
>> that you would want to change '<-' is because
>> of some extra side effect that you want to happen.
>> That is not in the spirit of R.
> Yes, I wanted some side effect of '<-', to have my own reference
> counting for some large resource. I guess this is already the most
> non-intrusive way I can think of--initially I modified R's source
> code, an even worse option.

External pointers are the standard way to do that.  You don't need to 
worry about reference counting, R's garbage collector will call a 
finalizer when it doesn't need the object any more.

I think the usual example of this is the RODBC package, which maintains 
database connections that way.

If it and the Writing R Extensions manual aren't enough docs for you, 
you should probably move the question to the R-devel list:  this is 
pretty technical for R-help.

Duncan Murdoch




More information about the R-help mailing list