Re: [Rcpp-devel] Pass a function name as an argument.

2013-05-18 Thread Xiao He
Awesome. Thank you Baptiste! On Sat, May 18, 2013 at 4:32 PM, baptiste auguie wrote: > Hi, > > I asked the same thing once, and Dirk came up with some helpful ideas and > a whipped up a demo for the gallery > > > http://stackoverflow.com/questions/14428687/rcpparmadillo-pass-user-defined-function

Re: [Rcpp-devel] Pass a function name as an argument.

2013-05-18 Thread baptiste auguie
Hi, I asked the same thing once, and Dirk came up with some helpful ideas and a whipped up a demo for the gallery http://stackoverflow.com/questions/14428687/rcpparmadillo-pass-user-defined-function http://gallery.rcpp.org/articles/passing-cpp-function-pointers/ HTH, baptiste On 18 May 2013 1

Re: [Rcpp-devel] Pass a function name as an argument.

2013-05-18 Thread Xiao He
Hi JJ, Thank you for the reply. I would actually like to pass C++ functions to the C++ function foo(). To be more specific, the user will indicate in the R environment which of the two functions (fun1 or fun2) to pass to foo(). foo() will somehow use the chosen one accordingly. I suppose one optio

Re: [Rcpp-devel] Pass a function name as an argument.

2013-05-18 Thread JJ Allaire
Hi Xiao, The problem is that sourceCpp can only accept arguments of types that can be converted to R using Rcpp::as (this is detailed in the help topic for sourceCpp and in the Rcpp vignettes). Plain C function pointers aren't convertible in this fashion so the compilation fails. If your intentio