[Rcpp-devel] Rcpp::exception + threads = disaster

JJ Allaire jj.allaire at gmail.com
Sat Feb 8 21:28:22 CET 2020


I think the point is that the *only* reason Rcpp::stop exists is to do
forwarding to Rf_error. If that isn't your intention it's strictly worse
than a normal C++ exception.

Agreed that it would be good to have more clear docs here. Note that as
Dirk pointed out both Writing R Extensions and RcppParallel docs are pretty
clear about the fact that you shouldn't call any R APIs when in a
background thread.

On Sat, Feb 8, 2020 at 3:23 PM Joshua N Pritikin <jpritikin at pobox.com>
wrote:

> On Sat, Feb 08, 2020 at 02:55:06PM -0500, JJ Allaire wrote:
> >    Yes, the only reason to use Rcpp::stop is because you want a C++
> >    exception translated safely into an Rf_error at the SEXP call level.
> If
> >    you are trying to signal an error from a background thread you would
> >    want to use a regular C++ exception rather than Rcpp::stop.
>
> I'm disappointed that there is no interest in making Rcpp::stop work
> in both contexts.
>
> At a minimum, the distinct uses of C++ exceptions and Rcpp::stop
> should be documented better.
>
> --
> Joshua N. Pritikin, Ph.D.
> Virginia Institute for Psychiatric and Behavioral Genetics
> Virginia Commonwealth University
> PO Box 980126
> 800 E Leigh St, Biotech One, Suite 1-133
> Richmond, VA 23219
> http://exuberant-island.surge.sh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20200208/90b2a62f/attachment.html>


More information about the Rcpp-devel mailing list