Gets a representation of a promise without forcing the promise

getPromiseVar(name, env)

Arguments

name

The name of the variable

env

The environment in which to evaluate

Value

An object of class ".vsc.promise"; 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)
#> $code #> { #> message("evaluating promise...") #> 1L #> } #> #> $environment #> <environment: 0x7ff880ac8e10> #> #> $evaluated #> [1] FALSE #> #> attr(,"class") #> [1] ".vsc.promise" ".vsc.internalClass"
## evaluate it... base::print(e$x)
#> evaluating promise...
#> [1] 1
## 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)
#> $code #> { #> message("evaluating promise...") #> 1L #> } #> #> $environment #> NULL #> #> $evaluated #> [1] TRUE #> #> $value #> [1] 1 #> #> attr(,"class") #> [1] ".vsc.promise" ".vsc.internalClass"