Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upExtract Rcpp::unwindProtect() from Rcpp::Rcpp_fast_eval() #873
Conversation
Just this week I was wondering / wishing for something like this. Nice. Will rev.dep check once I get home. |
|
Also no real objections to the renaming, but I might just suggest to phase it in. Eg when I made the (by the years overdue) update to the Something like that may be prudent here. |
|
But none of the symbols I'm proposing to rename have been released to CRAN? |
|
But we are changing the API -- |
|
I think we only have |
|
Maybe. Well then my proposal would be to also rename |
Codecov Report
@@ Coverage Diff @@
## master #873 +/- ##
=======================================
Coverage 90.09% 90.09%
=======================================
Files 71 71
Lines 3271 3271
=======================================
Hits 2947 2947
Misses 324 324
Continue to review full report at Codecov.
|
|
Agreed, but then let's rename |
|
One risk is that (for better or worse) we already encourage the use of |
|
The C++11 interface with |
I think this is fine. When we document this API, we should make it clear that these callbacks cannot throw and are implicitly In the case of a stateful function object, all allocations should be made on the safe side of the C++ stack, i.e. before calling The situation is similar to destructors which should not throw as well. Edit: Bottom line this is mostly provided for syntactic purposes, so you can call C functions from a simple C++11 lambda. |
Do we? I tend to warn against flattened namespaces when I teach Rcpp. Do we make a recommendation somewhere? (That said, your point is of course very valid. We should not clash.) |
|
Should I send a renaming PR from which we could assess name clashes in revdeps? |
|
Why don't we stage things? Test (and possibly merge) this, then move on to the next. The bigger problem, as with the on-list discussion of the gentleman bitten by the RNG scoping, is the code we do not see. Something like |
Oh yes, I wasn't planning to send one right away.
I see, at first I thought it would produce duplicate symbol errors but of course it wouldn't because these |
|
Sorry, I was imprecise. If indeed user A has both |
|
@eddelbuettel I forgot to mention that the revdeps should be built with Edit: Let me know when revdeps are finished, I'll rebase on master for linear git history (I forgot to pull upstream before creating this branch). |
|
Dang, of course. Thanks for the reminder, @lionel- -- correcting and restarting. |
|
PR went fine, log committed, merging. |
I was planning to release with this define already in the Makevars. Is there any hard decision on this? |
|
We cannot do that as it breaks a few key packages (reticulate, v8) and also affects tidyxl. So for now this has to be per-user and local. (Also if we set it for good we would set it in a header file.) |
|
I mean, I was planning to release my package with this enabled by default, because it works like a charm. But if you plan to change the final name of the define, I should wait. |
|
I am sorry @Enchufa2 I missed the boat here: Yes, that is absolutely fine, and will give your package user the speed increase. I think this version "should" hit CRAN next month, I can roll one up for the Rcpp drat if you need it now. |
|
Great! There is no rush, my release should hit CRAN next month too. Thanks. |
This extracts the protecting logic from Rcpp_fast_eval into a new API function
Rcpp::unwindProtect(). It is meant for calling any C function that might longjump, for example a function from R's C API.When compiling against C++11, a
std::functionoverload allows to use function objects or lambdas:For C++98 a C-style callback interface is provided:
I have been thinking we should remove the
Rcpp_prefix fromRcpp_fast_eval(). In fact I think it should becomeRcpp::eval(). This makes even more sense since we have switched the.eval()methods of classes (such asLanguage::eval()) to be synonymous with.fast_eval()methods. The latter should likely be deprecated in the long term. Any objection to rename toRcpp::eval()?Also given the API is becoming more general and no longer focused on R evaluation only (and a
Rcpp::tryCatch()function is coming up), I think we should rename the defineRCPP_PROTECTED_EVALtoRCPP_USE_UNWIND_PROTECT.