-
Notifications
You must be signed in to change notification settings - Fork 20
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
Equivalent environments are seen as different when named #161
Comments
Named environments are deliberately compared by reference as of #133. I made that change as part of #127 (comment) — waldo compares generally compares environments by values but it compare named environments by reference because these are usually special environments (i.e. empty/base/global and packages environments). Can you please explain where you saw this problem? |
Sure, it did happen in artificial cases as you expected. The package {constructive} prints idiomatic building code from objects, this includes environments with all the caveats that this entails. It uses Waldo to confirm that the generated code is faithful to the object. # devtools::install_github("cynkra/constructive")
library(constructive)
e1 <- new.env()
e1$x <- 1
attr(e1, "name") <- "my_env"
# identical but uninteresting
construct(e1)
#> constructive::env("0x11bd168a0", parents = "global")
# not identical but equivalent, and interesting
construct(e1, opts_environment(constructor = "list2env"), check = TRUE)
#> list2env(list(x = 1), parent = .GlobalEnv) |>
#> structure(name = "my_env")
#> Error in `check_round_trip()`:
#> ! {constructive} couldn't create code that reproduces perfectly the input
#> `original` is <env:my_env>
#> `recreated` is <env:my_env> Created on 2023-04-11 with reprex v2.0.2 It's important for {constructive} not to choke even on rare cases because we'd like the package to be a robust tool to investigate corrupt or weird objects. You mentioned already in #152 that you expect regular objects in waldo so this issue might be out of scope. In this case I might be able to special case this with a |
I'm going to close this issue because I think it is out of scope, and it sounds like you have a work around. |
Created on 2023-03-30 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: