-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R_tryEval implementation #523
Comments
Pull requests welcome! The implementation should be fairly simple, but I'm not sure what is expected in the event of error. See the implementation fo Rf_eval:
|
If fear I'm not enough skilled to submit a PR on this topic, sorry. |
The documentation for how this should behave is a bit sparse but the following snippet from the embedded guide says the following: Handling Errors Example int
callFoo()
{
SEXP e, val;
int errorOccurred;
int result = -1;
PROTECT(e = allocVector(LANGSXP, 1));
SETCAR(e, Rf_install("foo"));
val = R_tryEval(e, R_GlobalEnv, &errorOccurred);
if(!errorOccurred) {
PROTECT(val);
result = INTEGER(val)[0];
UNPROTECT(1);
} else {
fprintf(stderr, "An error occurred when calling foo\n");
fflush(stderr);
}
/* Assume we have an INTSXP here. */
UNPROTECT(1); /* e */
return(result);
} Note that this will, by default, take care of handling all types of errors that R would usually handle including signals. So if the user sends an interrupt to a computation (e.g. using Ctrl-C) while an R expression is being evaluated, R_tryEval will return and report an error. If the host application however changes the signal mask and/or handlers from R's own ones, of course this will not necessarily happen. In other words, the host application can control the signal handling differently |
R_tryEval is currently not supported:
https://github.com/bedatadriven/renjin/blob/master/tools/gnur-runtime/src/main/java/org/renjin/gnur/api/Rinternals.java#L2256
Can we hope any workaround in the future?
The text was updated successfully, but these errors were encountered: