Skip to content
Prev 12572 / 63461 Next

Finalization and external pointers

On Mon, 3 May 2004, Duncan Murdoch wrote:

            
I added some notes I have on weak references and finalization at

	http://www.stat.uiowa.edu/~luke/R/weakfinex.html

The notes are a bit old but I think still apply, such as they are.

The onexit argument sets a flag; when R exits normally it will attempt
to run the finalizers of all references with this flag set.

The simple examples in these notes may be of use, or not.  The Haskell
reference may also be worth a look as one writeup of the issues.

Making sure you have the right match of object lifetimes with object
identities is probably the trickiest issue--do you need to make sure
two ways of asking for an R reference to the same physical window
return the same R pointer object? Probably you do; that will affect
the design in that the pointer object you use has to exist as long as
the physical window does.  Also keep in mind that these things could
get saved in a workspace (they will be restored with NULL pointers).

Best,

luke