You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
?env_unbind seems to imply that inherit = TRUE will remove a binding from all ancestors:
# With inherit = TRUE, it removes bindings in parent environments# as well:parent<- env(empty_env(), foo=1, bar=2)
env<- env(parent, foo="b")
env_unbind(env, "foo", inherit=TRUE)
env_has(env, c("foo", "bar"))
env_has(env, c("foo", "bar"), inherit=TRUE)
but this is not the case, with the last two lines evaluating to
env_has(env, c("foo", "bar"))
#> foo bar #> FALSE FALSE
env_has(env, c("foo", "bar"), inherit=TRUE)
#> foo bar #> TRUE TRUE
Perhaps this could become
# With inherit = TRUE, it can remove bindings in parent environments# as well:parent<- env(empty_env(), foo=1, bar=2)
env<- env(parent, foo="b")
env_unbind(env, "foo", inherit=TRUE) # removes from `env`
env_unbind(env, "foo", inherit=TRUE) # removes from `parent`
env_has(env, c("foo", "bar"))
#> foo bar #> FALSE FALSE
env_has(env, c("foo", "bar"), inherit=TRUE)
#> foo bar #> FALSE TRUE
Additionally, it would be nice if the documentation guaranteed [a certain warning/error behavior when attempting to remove a binding that doesn't exist. Currently, that behavior is no error or warning if no binding is found to remove. (I originally thought this matched mutate behavior and would be handy for implementing mutate-like verbs, but although mutate allows you to "remove" nonexistent columns, the error message when attempting to remove grouping columns (! `vars` missing from `data`: [...]) suggests that's not supposed to be the case. So name-checking logic still seems like something that would need to be handled downstream in this case.)]
The text was updated successfully, but these errors were encountered:
brookslogan
changed the title
Minor ?env_unbind issues: inherit example, include nonexistent binding behavior
Minor ?env_unbind issues: inherit example, undocumented behaviors
Sep 3, 2024
?env_unbind
seems to imply thatinherit = TRUE
will remove a binding from all ancestors:but this is not the case, with the last two lines evaluating to
Perhaps this could become
Additionally, it would be nice if the documentation guaranteed [a certain warning/error behavior when attempting to remove a binding that doesn't exist. Currently, that behavior is no error or warning if no binding is found to remove. (I originally thought this matched
mutate
behavior and would be handy for implementingmutate
-like verbs, but althoughmutate
allows you to "remove" nonexistent columns, the error message when attempting to remove grouping columns (! `vars` missing from `data`: [...]
) suggests that's not supposed to be the case. So name-checking logic still seems like something that would need to be handled downstream in this case.)]The text was updated successfully, but these errors were encountered: