getPromiseVar: Get a representation of a promise

View source: R/defaultVarInfoHelpers.R

getPromiseVarR Documentation

Get a representation of a promise

Description

Gets a representation of a promise without forcing the promise

Usage

getPromiseVar(name, env)

Arguments

name

The name of the variable

env

The environment in which to evaluate

Value

An object of class .vsc.promise or .vc.promiseDetails, depending on the option vsc.showPromiseDetails. The two classes are functionally identical and only rendered differently. A named list containing the expression that will be evaluated, the status whether the promise has already been evaluated, the value if it has already been evaluated, and the environment in which the unevaluated promise will be evaluated.

Examples

## create a promise
e <- new.env()
delayedAssign("x", {message("evaluating promise..."); 1L}, assign.env = e)
vscDebugger:::getPromiseVar("x", e)

## evaluate it...
base::print(e$x)

## is it still a promise? (It depends...)
stopifnot(vscDebugger:::isPromise("x", e, strict = FALSE))
stopifnot(!vscDebugger:::isPromise("x", e, strict = TRUE))

## get info again
vscDebugger:::getPromiseVar("x", e)


ManuelHentschel/vscDebugger documentation built on April 13, 2025, 8:59 p.m.