[Rcpp-devel] R.e. loadRcppModules

Christian Gunning xian at unm.edu
Thu Apr 14 07:43:56 CEST 2011


On Tue, Apr 12, 2011 at 11:07 PM, Romain Francois
<romain at r-enthusiasts.com> wrote:
>>
>> Just to clarify --  does your plan include storing user-modified
>> fields and properties in objects?  E.g. below, modtest with the msg
>> set?
>
> yes. Although the way I see it, this will require more work for the
> developper, who would have to provide a serialization/deserialization couple
> for his/her classes.
>
> This is a nice goal for a future version.

Am I naive to think that a 1-to-1 mapping between C++ object fields &
properties and an S4 object might make sense?  This reduces the module
developer's problem of serial/deserialization to 1) writing a
constructor (and perhaps with validator) that takes an S4 object, and
2) writing a finalizer that populates a specified S4 object in the
user's environment, tears down the C++ object (as per R Exts manual),
and let's save() do the rest?

It seems that, in theory, there's a canonical mapping between the
names/types of fields/properties exposed in the RCPP_MODULE call and
the proposed S4 object.  The main gotcha I see here is that any
variable within a C++ object *not* exposed as a field/property must be
viewed as a const to ensure consistency of the C++ object between
write and re-construct...

If this is off-base, feel free to ignore or point out good reading material :)
-christian

-- 
A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!


More information about the Rcpp-devel mailing list