fn_env

0th

Percentile

Return the closure environment of a function.

Closure environments define the scope of functions (see env()). When a function call is evaluated, R creates an evaluation frame (see eval_stack()) that inherits from the closure environment. This makes all objects defined in the closure environment and all its parents available to code executed within the function.

Usage
fn_env(fn)
fn_env(x) <- value
Arguments
fn, x
A function.
value
A new closure environment for the function.
Details

fn_env() returns the closure environment of fn. There is also an assignment method to set a new closure environment.

Aliases
  • fn_env
  • fn_env<-
Examples
env <- new_env("base")
fn <- with_env(env, function() NULL)
identical(fn_env(fn), env)

other_env <- new_env("base")
fn_env(fn) <- other_env
identical(fn_env(fn), other_env)
Documentation reproduced from package rlang, version 0.0.0.9000, License: GPL-3

Community examples

Looks like there are no examples yet.