-
-
Notifications
You must be signed in to change notification settings - Fork 219
Switch from Rf_findVarInFrame to R_getVarEx #1423
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
base: master
Are you sure you want to change the base?
Conversation
kevinushey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits around the value we pass for inherits.
inst/include/Rcpp/Environment.h
Outdated
| SEXP res = Rf_findVarInFrame( env, nameSym ) ; | ||
|
|
||
| #else | ||
| SEXP res = R_getVarEx(nameSym, env, TRUE, R_UnboundValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| SEXP res = R_getVarEx(nameSym, env, TRUE, R_UnboundValue); | |
| SEXP res = R_getVarEx(nameSym, env, FALSE, R_UnboundValue); |
I believe we want inherits = FALSE here since Rf_findVarInFrame() won't look through parent environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually had to trace around a test failure and flipped one of the other booleans. We will need to look at all of these. So appreciate the second set of eyes. Will change, and we should doube-triple check the others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 7636fec
inst/include/Rcpp/Environment.h
Outdated
| #if R_VERSION < R_Version(4,5,0) | ||
| SEXP res = Rf_findVarInFrame( env, name ) ; | ||
| #else | ||
| SEXP res = R_getVarEx(name, env, TRUE, R_UnboundValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| SEXP res = R_getVarEx(name, env, TRUE, R_UnboundValue); | |
| SEXP res = R_getVarEx(name, env, FALSE, R_UnboundValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 7636fec
| #if R_VERSION < R_Version(4,5,0) | ||
| Rcpp_cache = Rf_findVarInFrame(RCPP, Rf_install(".rcpp_cache")); | ||
| #else | ||
| Rcpp_cache = R_getVar(Rf_install(".rcpp_cache"), RCPP, TRUE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Rcpp_cache = R_getVar(Rf_install(".rcpp_cache"), RCPP, TRUE); | |
| Rcpp_cache = R_getVar(Rf_install(".rcpp_cache"), RCPP, FALSE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one I was more torn about. Note the comment just above the code:
/**
* Get an object from the environment or one of its
* parents
*
* @param name name of the object
*
*/
SEXP find( const std::string& name) const{So does is walk through the other envs?
Also note that lines 139 to 162 (for find(std::string)) and 164 to 188 (for find(Symbol)) should be symmetric. Both TRUE, or both FALSE?
7636fec to
3f4ff02
Compare
|
Rebased once more |
Closes #1421
As described in #1421, this is another upcoming R API tightening. This fairly narrow PR does this, keeping the old code til we can remove it a few years from now and switches to the new functions for R 4.5.0 or newer.
We should leave this open until the reverse dependency checks give us a view into what the impact may be.
Checklist
R CMD checkstill passes all tests