<p dir="ltr">RStan doesn't do anything to persist any c++ object.  What's done is to save the binary file created using package inline in an R object so it can be reused without recompiling c++ code.  So what is in cxxfunplus might not be related.</p>

<p dir="ltr">Jiqiang</p>
<div class="gmail_quote">On Mar 20, 2014 11:53 AM, "Dirk Eddelbuettel" <<a href="mailto:edd@debian.org">edd@debian.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On 20 March 2014 at 18:39, F.Tusell wrote:<br>
| I have been reading "Exposing C++ functions and classes with Rcpp<br>
| modules" and find the idea interesting. However, I read in Section 5<br>
| that objects created<br>
| using an external pointer are not persistent from session to session.<br>
<br>
Yes. The memory behind that pointer is not guaranteed...<br>
<br>
| For my purposes, I think I could use S4 objects that make C++ copies of<br>
| themselves at creation time, accessible via an external pointer. All<br>
| methods would then make use of the C++ copies for speed, and at the end<br>
| of the session the S4 copies that live in the R side would be saved.<br>
|<br>
| I am thinking of writing code which at the start of a session checks all<br>
| (S4) objects in the workspace and recreate the C++ copies. Is this the<br>
| way to go? Has someone with a similar problem devised an alternative<br>
| solution? If anyone can offer some hints (or better yet, point to some<br>
| package that I can use for inspiration) I would  be grateful.<br>
<br>
The Stan folks also did something about this in an extension / rework of<br>
cxxfunction in inline -- see their package cxxfunplus on CRAN. (Which I<br>
haven't used so I can't help with details -- but it help you or point you the<br>
right way.)<br>
<br>
Dirk<br>
<br>
--<br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a><br>
_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
</blockquote></div>