# env_assign_lazily

0th

Percentile

##### Assign a promise to an environment.

These functions let you create a promise in an environment. Such promises behave just like lazily evaluated arguments. They are evaluated whenever they are touched by code, but not when they are passed as arguments.

##### Usage
env_assign_lazily(env = env_caller(), nm, expr, eval_env = NULL)
env_assign_lazily_(env = env_caller(), nm, expr, eval_env = NULL)
##### Arguments
env
An environment or an object with a S3 method for env(). If missing, the environment of the current evaluation frame is returned.
nm
The name of the binding.
expr
An expression to capture for env_assign_lazily(), or a captured expression (either quoted or a formula) for the standard evaluation version env_assign_lazily_(). This expression is used to create a promise in env.
eval_env
The environment where the promise will be evaluated when the promise gets forced. If expr is a formula, its environment is used instead. If not a formula and eval_env is not supplied, the promise is evaluated in the environment where env_assign_lazily() (or the underscore version) was called.

env_assign()

##### Aliases
• env_assign_lazily
• env_assign_lazily_
##### Examples
env <- env_new()
env_assign_lazily(env, "name", cat("forced!\n"))
env$name # Use the standard evaluation version with quoted expressions: f <- ~message("forced!") env_assign_lazily_(env, "name2", f) env$name2

Documentation reproduced from package rlang, version 0.0.0.9000, License: GPL-3

### Community examples

Looks like there are no examples yet.