[Rcpp-devel] expose functions dynamically
David Bellot
david.bellot at gmail.com
Mon Dec 4 16:44:10 CET 2017
Hi,
I'd like to dynamically add functions to a module when I call one of its
function. Later I will want to do the same for classes too, so that to
create classes "on the fly".
But for the moment, here is what I try to do and it doesn't work, because I
can't see my dynamically created function in R
#include <Rcpp.h>
using namespace Rcpp;
double foobar(int x)
{
return x*2.0;
}
void makef()
{
function("dynfoo",&foobar);
}
RCPP_MODULE(test1)
{
function("foobar",foobar);
function("makef",&makef);
}
Then in R, I call the function makef hoping to see the function dynfoo
appears in my global environment in R. It's not the case. I suspect a
problem with scope (or something like that) ?
- What is the correct way to do that ?
- Can I create my functions in other environment too ?
Best,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20171204/4da53ed4/attachment.html>
More information about the Rcpp-devel
mailing list