scope <- new_env(base_env(), list(a = 10))
fn <- function() a
env(fn) <- scope
# fn() sees a = 10:
fn()
# env_bury() will bury the current scope of fn() behind a new
# environment:
fn <- env_bury(fn, list(a = 1000))
fn()
Run the code above in your browser using DataLab