[Rcpp-devel] Modules docs

Dominick Samperi djsamperi at gmail.com
Thu Dec 9 00:23:02 CET 2010


On Wed, Dec 8, 2010 at 6:15 PM, Romain Francois <romain at r-enthusiasts.com>wrote:

> I'm not sure which version of the vignette you are referring to, but the
> one on CRAN (related to Rcpp 0.8.9) recommends to have this in the
> NAMESPACE:
>
> import(Rcpp)
>
> This might be conservative and you might end up importing too much. I don't
> see much of a downside to it.
>

What I am seeing is that if I load the client package and this package
does not use import(Rcpp), or importClassesFrom(...), or anything like this,
I
still get correct output from:

showClass('Module')
showClass('C++Class')
etc.

And the modules defined by the client package seem to work fine.

Thus it appears that the fact that Rcpp exports the necessary
classes and the client package runs library(Rcpp) is enough.

But perhaps there are situations where this will not work...

Thanks,
Dominick


> Le 08/12/10 21:21, Dominick Samperi a écrit :
>
>> To be more concrete, I define a module in foo.cpp and do something like
>> this:
>>
>> foo = Module("MyClass", PACKAGE="MyPack")
>> foo$myfunc()
>>
>> Where myfunc() is defined using function() in the RCPP_MODULE macro. I
>> can also extract the underlying reference and work with that as well.
>>
>> This works without the importClassFrom() directive.
>>
>> On Wed, Dec 8, 2010 at 1:55 PM, Dominick Samperi <djsamperi at gmail.com
>> <mailto:djsamperi at gmail.com>> wrote:
>>
>>    I have a question about the modules vignette.
>>
>>    At the end it says client packages must importClassesFrom(...),
>>    and there are comments about using .onLoad() as well.
>>
>>    But before reading this I already implemented the use of
>>    modules in another (client) package without using these
>>    constructions. They do not seem to be required?
>>
>>    Can you elaborate on exactly when these constructions
>>    are needed?
>>
>>    Thanks,
>>    Dominick
>>
>
>
> --
> Romain Francois
> Professional R Enthusiast
> +33(0) 6 28 91 30 30
> http://romainfrancois.blog.free.fr
> |- http://bit.ly/fT2rZM : highlight 0.2-5
> |- http://bit.ly/gpCSpH : Evolution of Rcpp code size
> `- http://bit.ly/hovakS : RcppGSL initial release
>
>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20101208/e8688501/attachment.htm>


More information about the Rcpp-devel mailing list