[Rcpp-commits] r1140 - pkg/Rcpp/inst/announce

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun May 2 19:35:31 CEST 2010


Author: romain
Date: 2010-05-02 19:35:31 +0200 (Sun, 02 May 2010)
New Revision: 1140

Modified:
   pkg/Rcpp/inst/announce/ANNOUNCE-0.8.0.txt
Log:
some blurb about exceptions

Modified: pkg/Rcpp/inst/announce/ANNOUNCE-0.8.0.txt
===================================================================
--- pkg/Rcpp/inst/announce/ANNOUNCE-0.8.0.txt	2010-05-02 17:19:31 UTC (rev 1139)
+++ pkg/Rcpp/inst/announce/ANNOUNCE-0.8.0.txt	2010-05-02 17:35:31 UTC (rev 1140)
@@ -172,8 +172,13 @@
 
 ===== C++ exceptions =====
 
-Rcpp forwards exceptions as R conditions using the C++ function
-"forward_exception_to_r". For example : 
+C++ exceptions are R contexts are both based on non local jumps (at least 
+on the implementation of exceptions in gcc), so care must be ensure
+that one system does not void assumptions of the other. It is therefore 
+very strongly recommended that each function using c++ catches 
+c++ exceptions. Rcpp offers the function forward_exception_to_r
+to facilitate forwarding the exception to the "R side" as an R condition. 
+For example : 
 
 SEXP foo( ){
 	try{
@@ -181,6 +186,7 @@
 	} catch( std::exception& __ex__){
 		forward_exception_to_r( __ex__ ) ;
 	}
+	// return something
 }
 
 Alternatively, functions can enclose the user code with the macros BEGIN_RCPP
@@ -190,9 +196,14 @@
 	BEGIN_RCPP
 	// user code
 	END_RCPP
+	// return something
 }
 
+The use of BEGIN_RCPP and END_RCPP is recommended to anticipate future changes
+of Rcpp. We might for example decide to install dedicated handlers for specific 
+exceptions later.
 
+
 ===== Quality Assurance =====
 
 Rcpp uses the packages RUnit and inline to manage unit tests of Rcpp. Rcpp



More information about the Rcpp-commits mailing list