rlang (version 0.0.0.9000)

env_bury: Bury bindings and define objects in new scope.

Description

env_bury() is like env_bind() but it creates the bindings in a new child environment. Note that this function does not modify its inputs.

Usage

env_bury(env = caller_env(), data = list())

Arguments

env
An environment or an object with a S3 method for env(). If missing, the environment of the current evaluation frame is returned.
data
A vector with unique names which defines bindings (pairs of name and value). See is_dictionary().

Value

An object associated with the new environment.

Examples

Run this code
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 DataCamp Workspace