Hi Guiseppe, Thanks for reposting here!
On 30 April 2010 at 16:07, Giuseppe Milicia wrote: | Guys, | | I posted this on R-help and Dirk kindly pointed out that this list is a much better place for this sort of questions... | | I was wondering whether anyone experimented with Rcpp and static | variables. I remember reading that Rcpp is essentially stateless. That | makes sense. However I just run a piece of code that contains a static STL | structure, surprisingly it seems that those static variables are | preserved... I have not used it explicitly. But I do use code in production that instantiates singletons etc to keep e.g. connection handles to a backend. I initialize this on package load -- using a nice clean hook provided by R and then hold on to it until the package unloads, which in practice is when the R session ends. That works cleanly via constructor and deconstructor calls. | The question is, can we use static variable to reliably preserve state | between Rcpp calls? If this is the case, this should be a better way to | store state than by passing state variables between R and C++. I don't see why not. Can you mock up an example of what you are trying to do? -- Regards, Dirk _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
