env_bury

0th

Percentile

Overscope bindings by defining symbols deeper in a scope

env_bury() is like env_bind() but it creates the bindings in a new child environment. This makes sure the new bindings have precedence over old ones, without altering existing environments. Unlike env_bind(), this function does not have side effects and returns a new environment (or object wrapping that environment).

Usage
env_bury(.env, ...)
Arguments
.env

An environment or an object bundling an environment, e.g. a formula, quosure or closure. This argument is passed to get_env().

...

Pairs of names and expressions, values or functions. These dots support splicing (with varying semantics, see above) and name unquoting.

Value

A copy of .env enclosing the new environment containing bindings to ... arguments.

See Also

env_bind(), env_unbind()

Aliases
  • env_bury
Examples
# NOT RUN {
orig_env <- env(a = 10)
fn <- set_env(function() a, orig_env)

# fn() currently sees `a` as the value `10`:
fn()

# env_bury() will bury the current scope of fn() behind a new
# environment:
fn <- env_bury(fn, a = 1000)
fn()

# Even though the symbol `a` is still defined deeper in the scope:
orig_env$a
# }
Documentation reproduced from package rlang, version 0.1.6, License: GPL-3

Community examples

Looks like there are no examples yet.