Skip to content
Prev 35493 / 63424 Next

R_PreserveObject, R_ReleaseObject : reference counting needed ?

On 01/02/2010 10:26 PM, Whit Armstrong wrote:
that's not what I said. It just felt not as easy to use as just grab a 
SEXP and say R_PreserveObject( x ) and then later R_ReleaseObject.

I did not mean to discourage people from using it. It is probably very 
stable indeed since it is used all over the place in the parser, and 
since the parser is probably the most used code in the R source tree, we 
would know if it did not work properly.
>
Thanks. I'll have a look.
Dirk is proving very cooperative and the "Rcpp" package is under a lot 
of changes currently in its new Rcpp namespace, while keeping the 
current interface.

Our main class is Rcpp::RObject that wraps any SEXP into a C++ object 
that basically R_PreserveObject when it is created, and R_ReleaseObject 
when the object is destroyed.

deriving from "RObject", we have "Environment" to deal specifically with 
environments (ENVSXP) , "Symbol" to deal with symbols (SYMSXP), 
"Language" for calls (LANGSXP) and the template XPTr for external 
pointers. The rest (vectors, functions, ...) will follow.

I'd suggest using the Rcpp mailing list for a follow up. 
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel