[Rd] R_PreserveObject, R_ReleaseObject : reference counting needed ?

Laurent Gautier lgautier at gmail.com
Sat Jan 2 19:02:54 CET 2010


On 1/2/10 5:50 PM, Romain Francois wrote:
> Thanks.
>
> On 01/02/2010 05:36 PM, Laurent Gautier wrote:
>>
>> [Disclaimer: what is below reflects my understanding from reading the R
>> source, others will correct where deemed necessary]
>>
>> On 1/2/10 12:00 PM, r-devel-request at r-project.org wrote:

(...)

>>
>>> In particular, if we preserve the same SEXP twice (or more), should we
>>> implement some sort of reference counting ?
>>
>> This depends on the requirements for your system.
>
> We wrap up SEXP into a C++ class that in particular manages itself
> preserving and releasing the object to garbage collection.

If you do not allow several C++ instances to share the same SEXP, you 
should not need reference counting. In the case of rpy2, this was made 
necessary for allowing inheritance (as nested calls to constructors can 
cause a transient sharing of the given SEXP across several Python objects).


(...)



L.



More information about the R-devel mailing list