On 20 October 2012 at 03:11, Christian Gunning wrote: | > What I would really do here is to create a simple struct or rather class that | > upon initialization creates the workspace and holds it. | > | > Doesn't fit as easily in the inline paradigm though. | | Can one place object definitions in includes and then use them in the | body? I'm rusty on inline -- I recall placing functions in includes, | but I don't recall doing this. The inline docs are a little thin on | examples here.
Oh c'mon we have dozens of examples in the list archives. So here is another one -- try with verbose=FALSE to see more: R> library(inline) # assume 0.3.10 for rcpp() R> inc <- 'const int answer = 42;' R> src <- 'Rcpp::Rcout << "The anwer to everything is " + << answer << std::endl;' R> f <- rcpp(signature(), body=src, inc=inc) R> f() The anwer to everything is 42 NULL R> The included segment can have any and all valid code segments: class definitions, function definitions, other includes, ... Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel