[Rd] RE: A 'true' R-wrapper for C++ classes

Duncan Murdoch murdoch at stats.uwo.ca
Mon Apr 18 11:02:41 CEST 2005


> Sorry about the mistake in the previous post, here is the corrected
> version:

And I've just added responses to part of it:


> (3) The above model lacks something like an 'environment' for the pointer
> to
> the C++ object to live in it. Assume we create the foo class in R like:
>
>   obj <- foo$new()
>
> Now, the following would return an error:
>
>   obj$fun()
>
> and the reason is that the pointer created in the initialize method is
> lost.
>
> (4) The question is how to assign an environment to the pointers. A well
> described answer, rather than some abstract hints, is well-appreciated.

I think you'll have to ask the OOP author this one.  Generally R doesn't
have pointers, so when a package provides them, it needs to do a lot of
low level support for them.

> Also
> I am curious to know why there is no standard method for R to wrap C++
> classes, something like JNI.

I think it would be harder to write such a thing, in that R and C++ are
more different than Java and C++ are.

Duncan Murdoch



More information about the R-devel mailing list