[Rcpp-devel] loadRcppModules

Romain Francois romain at r-enthusiasts.com
Mon Apr 11 11:41:58 CEST 2011


I've added an experimental feature to Rcpp minutes ago.

This is to simplify (yet again) dealing with modules. Now, when one 
wants to use C++ functions and classes that are declared in a module, 
the only things you have to do are:

* declare them in the "RcppModules" field of DESCRIPTION file, for 
example (taken from the testRcppModule package, part of Rcpp's testing 

Package: testRcppModule
Type: Package
Title: Some test examples using Rcpp with the Module feature
Version: 0.1
Date: 2010-09-06
Author: JMC
Maintainer:  <jmc at stat.stanford.edu>
Description: Some examples taken (and perhaps modified) from the Rcpp 
Modules documentation.
License: GPL(>=2)
LazyLoad: yes
Depends: methods, Rcpp (>= 0.8.5)
LinkingTo: Rcpp
RcppModules: yada, stdVector, NumEx
Packaged: 2010-09-09 18:42:28 UTC; jmc

The relevant line being:

RcppModules: yada, stdVector, NumEx

* load them. We used to have to load them individually by calling Module 
and maybe populate. Now, this is simpler. You just need a .onLoad 
function that looks like this:

.onLoad <- function(libname, pkgname){

This will load the declared modules, and populate them into your 
package's namespace.

I will update the Rcpp-modules vignette accordingly.

Suggestions, comments, improvements, "what are you  ? nuts !", ... are 
always welcome.


Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
|- http://bit.ly/fhqbRC : Rcpp workshop in Chicago on April 28th
|- http://bit.ly/dFyZGB : Hydraulique au Montpellier Comedie Club
`- http://bit.ly/eVXit9 : Eponyme : 40 minutes stand up

More information about the Rcpp-devel mailing list