Gets a representation of a promise without forcing the promise
getPromiseVar(name, env)
name | The name of the variable |
---|---|
env | The environment in which to evaluate |
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.
## 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"#>#> [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"