[Rcpp-devel] rcpp_modules: Passing object pointer back to C++

Dirk Eddelbuettel edd at debian.org
Mon Jan 23 20:50:04 CET 2012


On 23 January 2012 at 15:36, Mr.M at gmx.at wrote:
| Hello again and thanks for the many replies.
| 
| Well, Dirk,
| 
| I haven't dealt with Rcpp and S4 long enough to understand every piece of it, so I'll try to explain my thoughts with examples.

[ ... lots of stuff deleted: a code example would have been nice ... ]

| So, the important questions (for an inexperienced Rcpp_modules user like me) are:
| 1) Does R call the destructor of rcpp_modules S4 C++ objects when the R GC unallocates them? (hopefully "yes")
| 2) Does R change the location of rcpp_modules S4 C++ objects in memory during their lifetime? (hopefully "no")

Yes, that is the broad idea.

The problem is that once back in R you never quite know when garbage
collection occurs.  For as long as objects are marked 'in use' you may be
fine.

I still don't see why one would want to muck with dangling C++ pointers at
the R level, but maybe I just need more or stronger coffee.

Dirk

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx


More information about the Rcpp-devel mailing list