[Rcpp-devel] Modules and default constructors

Romain Francois romain at r-enthusiasts.com
Fri Nov 19 19:09:27 CET 2010


Thanks.

The intention with the new, more flexible, constructors was that a 
default constructor was not required. But I have to admit that I have 
not experimented too much with inheritance, either on the C++ side (last 
remaining item on the TODO list for modules) or on the R side.

Romain

Le 19/11/10 18:59, John Chambers a écrit :
> There was a problem in that creating a subclass in R of an Rcpp class
> attempts to call a default constructor.
>
> I have code that fixed the problem, by creating a suitable $initialize()
> method based on the existence or not of the default C++ constructor, but
> unfortunately I have yet to fully test & commit the change, and I'm off
> in a few minutes for today.
>
> So, sorry, you probably still need a default constructor as a workaround
> if you intend to define a subclass but, with luck, soon you won't.
>
> John
>
> On 11/19/10 7:06 AM, Douglas Bates wrote:
>> I believe it is now recommended that a class to be exposed in a module
>> should expose a default constructor (i.e. a constructor called with no
>> arguments). Is such a constructor actually called or is it just there
>> to establish the necessary linkage? In a class where it would not
>> make sense to construct an object without arguments I was going to
>> have the default constructor throw an exception but that might not be
>> a good idea. I seem to recall the discussion between John and Romain
>> indicating that it must be called during the initialization of the
>> reference class in R.

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9VOd3l : ZAT! 2010
|- http://bit.ly/c6DzuX : Impressionnism with R
`- http://bit.ly/czHPM7 : Rcpp Google tech talk on youtube




More information about the Rcpp-devel mailing list