Skip to content
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

env_clone() does not reproduce active bindings faithfully #562

Closed
tmastny opened this issue Jul 25, 2018 · 1 comment
Closed

env_clone() does not reproduce active bindings faithfully #562

tmastny opened this issue Jul 25, 2018 · 1 comment

Comments

@tmastny
Copy link

tmastny commented Jul 25, 2018

Below is the reprex. It seems that eval_tidy returns the binding function, while eval returns the result of the function.

Is this the desired behavior?

library(rlang)
e <- new.env()
e$y <- 1
env_bind_fns(e, y = function(val) {print("getting called"); 1})
eval(expr(y), e)
#> [1] "getting called"
#> [1] 1
eval_tidy(expr(y), e)
#> function(val) {print("getting called"); 1}
eval_tidy(expr(y()), e)
#> [1] "getting called"
#> [1] 1

Created on 2018-07-24 by the reprex
package
(v0.2.0).

@lionel- lionel- changed the title Differences between eval and eval_tidy with env_bind_fns env_clone() does not reproduce active bindings faithfully Sep 3, 2018
@lionel-
Copy link
Member

lionel- commented Sep 3, 2018

That's because environments are cloned and env_clone() loses the binding info.

I'm thinking about deprecating environments, you'd have to pass a data mask built with new_data_mask() instead. Then there would be no cloning.

@lionel- lionel- closed this as completed in 395cf4a Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants