Skip to content

Conversation

@DavisVaughan
Copy link
Member

By making r_env_poke_parent() use base::parent.env<-. r_env_poke_parent() is now also internal to rlang and is not in the rlang C API.

It's worth looking at https://github.com/r-lib/rlang/blob/main/src/internal/eval-tidy.c to see the places where we currently use r_env_poke_parent(). I don't think any of them are particularly performance sensitive?

The R level env_poke_parent() still does the additional checks on top of what base::parent.env<- already does via ffi_env_poke_parent(). This lets us throw good error messages and I don't think it really costs us much. No one on CRAN (bundle, carrier, sparklyr) seems to be using this in a performance sensitive way anyways.
https://github.com/search?q=org%3Acran+env_poke_parent&type=code

The C level r_env_poke_parent() doesn't do any checks beyond what base::parent.env<- does, so it is up to the caller to ensure the data types are right, otherwise you'll get an error from base R, which may be suboptimal (but should never crash).

@@ -0,0 +1,6 @@
static
Copy link
Member Author

Choose a reason for hiding this comment

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

This decl file was named wrong. It was env-decl.h but was in env-binding.c. It should have been env-binding-decl.h, which I have fixed here to make room for the real env-decl.h that I've just added to.

@@ -1,4 +1,5 @@
#include <rlang.h>
#include "env.h"
Copy link
Member Author

Choose a reason for hiding this comment

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

Required so ffi_env_poke_parent() can see r_env_poke_parent()

@DavisVaughan DavisVaughan changed the title Drop SET_ENCLOS() usage Remove SET_ENCLOS() usage Oct 22, 2025
Base automatically changed from feature/rlang-c-api to main October 23, 2025 14:16
@DavisVaughan DavisVaughan force-pushed the feature/no-set-enclos branch from 85015f0 to 84d6b3f Compare October 23, 2025 14:32
@DavisVaughan DavisVaughan merged commit 472d23e into main Oct 23, 2025
11 checks passed
@DavisVaughan DavisVaughan deleted the feature/no-set-enclos branch October 23, 2025 14:42
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.

2 participants