Skip to content

Conversation

@eddelbuettel
Copy link
Member

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

  • Code compiles correctly
  • R CMD check still passes all tests
  • Preferably, new tests were added which fail without the change
  • Document the changes by file in ChangeLog

Copy link
Contributor

@kevinushey kevinushey left a 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.

SEXP res = Rf_findVarInFrame( env, nameSym ) ;

#else
SEXP res = R_getVarEx(nameSym, env, TRUE, R_UnboundValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member Author

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.

Copy link
Member Author

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)
SEXP res = Rf_findVarInFrame( env, name ) ;
#else
SEXP res = R_getVarEx(name, env, TRUE, R_UnboundValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SEXP res = R_getVarEx(name, env, TRUE, R_UnboundValue);
SEXP res = R_getVarEx(name, env, FALSE, R_UnboundValue);

Copy link
Member Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Rcpp_cache = R_getVar(Rf_install(".rcpp_cache"), RCPP, TRUE);
Rcpp_cache = R_getVar(Rf_install(".rcpp_cache"), RCPP, FALSE);

Copy link
Member Author

@eddelbuettel eddelbuettel Dec 13, 2025

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?

@eddelbuettel eddelbuettel changed the title Switch from Rf_findVarInFram to R_getVarEx Switch from Rf_findVarInFrame to R_getVarEx Dec 13, 2025
@eddelbuettel
Copy link
Member Author

Rebased once more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move away from Rf_findVarInFrame

3 participants