Re: [Rd] destructor for S4 class objects in analogy to C++

2009-07-21 Thread Simon Urbanek
David, On Jul 21, 2009, at 13:00 , David Scherrer wrote: I'm wondering if there is a way to define a destructor function (to free memory) for S4 class objects in analogy to C++? The analogy doesn't work, because in C++ you have pass-by-reference semantics, but in R you have pass-by-value.

Re: [Rd] destructor for S4 class objects in analogy to C++

2009-07-21 Thread Whit Armstrong
if you are using external pointers, then R allows you to set a finalizer function to be called on the pointer. http://cran.r-project.org/doc/manuals/R-exts.html#External-pointers-and-weak-references see examples in RODBC package. and here too: see the "connFinalizer" function http://github.com/a

[Rd] destructor for S4 class objects in analogy to C++

2009-07-21 Thread David Scherrer
Hi all, I'm wondering if there is a way to define a destructor function (to free memory) for S4 class objects in analogy to C++? rm() combined with gc() does not seem to be a good idea (Chambers, 2008). So could it be done on the C/C++ level or is it even already available in the "internals"? Man