<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 18, 2014 at 8:05 PM, 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=""><br>
On 18 June 2014 at 19:40, Tim Keitt wrote:<br>
|<br>
|<br>
|<br>
| On Wed, Jun 18, 2014 at 6:26 PM, Dirk Eddelbuettel <<a href="mailto:edd@debian.org">edd@debian.org</a>> wrote:<br>
|<br>
|<br>
| Tim,<br>
|<br>
| Step back for a second and recognise that everything happens via<br>
|<br>
| SEXP .Call(SEXP a, SEXP b, ...)<br>
|<br>
| where R calls your C++ routine asynchronously.<br>
|<br>
| You can do tricks _within the subroutine that is called_ which is<br>
| essentially<br>
| what happens via the automatically-added try/catch block we have in C++.<br>
| And<br>
| Rcpp::stop() is just a shortcut for using those.<br>
|<br>
|<br>
| Can I throw a condition (meaning an object inheriting class "condition") or am<br>
| I limited to strings? If I throw a condition, will it be raised as such?<br>
<br>
</div>See eg Section 2.7 titled "Exception Handling" in my Springer book on Rcpp.<br>
This is standard stuff, and we discussed the basics in the 2011 JSS paper.<br>
<br>
You can throw anything that is subclassed from std::exception, and catch it<br>
appropriately. The default mechanism is to take the exception text and pass<br>
it to R -- because, once again, passing a string is all we can do. _Your_<br>
code could course provide more complex things and keep them, and tickle (by<br>
error codes) retrieval via other functions.<br>
<br>
But again, the interface we are given by R is fixed. You can only be<br>
creative within the confines of that interface.<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div>Got it. Decided exceptions are evil and tore it out. Easy to return a status string.</div><div><br></div><div>THK</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">
Dirk<br>
<br>
--<br>
<a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><a href="http://www.keittlab.org/" target="_blank">http://www.keittlab.org/</a></div>
</div></div>