Skip to content

How to locate references to an environment?

1 message · Antoine Fabri

#
You could try {constructive} : https://github.com/cynkra/constructive/

Here's how it might help:

```
E <- new.env()
fun <- function(x) x
environment(fun) <- E
O <- list(
  a = 1,
  b = fun
)
# remotes::install_github("cynkra/constructive")
library(constructive)

construct(E)
#> constructive::env("0x1075b2380", parents = "global")

construct(O)
#> list(
#>   a = 1,
#>   b = (function(x) x) |>
#>     (`environment<-`)(constructive::env("0x1075b2380", parents =
"global"))
#> )
```

By searching for `0x1075b2380` here you'd easily find where it's referenced.
If you have S4 objects in there you might want to try again in a few days
since they're not supported yet.

If the output is too big consider `construct_dump(list(O = O), "out.R")`

Thanks,

Antoine