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.

#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?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if I'm missing something, but isn't this code just trying to get a reference to the .rcpp_cache variable in the Rcpp namespace?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the prior edits are preserving that behavior you suggest, though -- get => inherits = FALSE; find => inherits = TRUE.

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 think that is where we are at right now (i.e.: get has a FALSE, find has a TRUE) and that is due to one correction made after your comment made days ago (as noted above). And that seems fine.

(The 'just look for .rcpp_cache' is in a different file and seemingly a debugging-only helper.)

@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

@eddelbuettel
Copy link
Member Author

@kevinushey Do you want to take another look an Environment.h ? We now have the two get() with FALSE and not descending, and the two find() have TRUE. That seems to make sense and work in the (still-running) reverse-depends check.

@eddelbuettel
Copy link
Member Author

Reverse-depends checks turned up no new issues so all good from there too

@eddelbuettel eddelbuettel merged commit 582376a into master Dec 16, 2025
26 checks passed
@eddelbuettel eddelbuettel deleted the feature/use_R_getVar branch December 16, 2025 14:48
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