<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 8 October 2013 14:19, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
On 8 October 2013 at 13:53, Jon Clayden wrote:<br></div><div class="im">
| I think I do... ;)  I need the object to hold state and not be deallocated<br>
| between calls into the C++ code. I also want to allow for the possibility that<br>
| multiple Foo objects exist, and are being operated on simultaneously. So<br>
| holding a handle on the R side and passing it back to each C++ function that<br>
| works with the object seems like the natural approach to me.<br>
<br>
</div>A really simple way to do that is that create a container class that has this<br>
type as an object, and to create an init function, an accessor function, ...<br>
<br>
Rcpp modules can do that for you too just via declarations, resulting in<br>
Reference Class objects at the R level.  This is a little more advanced;<br>
maybe more suitable for your next project, or now if you are willing to read<br>
up (Rcpp modules vignette, corresponding chapter in the Rcpp book, existing<br>
packages, ...)<br></blockquote><div><br></div><div style>Right, thanks. I will read the modules vignette for a start.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">| Agreed, but it's a consideration. I fully accept that the choice depends on the<br>
| particular application, as you and Dirk both said. I was just wondering what<br>
| the baseline performance difference (if any) might be.<br>
<br>
</div>Nobody knows ex ante. There is no explicit slowdown baked in. As we have<br>
suggested several times, you need to measure it!</blockquote><div><br></div><div style>Yes, OK - poor phrasing on my part. I take the point.</div><div><br></div><div style>Jon</div><div style><br></div></div></div></div>