
Last chance! 50% off unlimited learning
Sale ends in
lazy(expr, envir = parent.frame(), substitute = TRUE, globals = TRUE,
local = TRUE, ...)
local
is TRUE)
and from which globals are obtained.expr
is
substitute()
:ed, otherwise not.plan(lazy)
such that it
becomes the default mechanism for all futures. After this
future()
and %<=%< a="">
will create
lazy futures.## A global variable
a <- 0
## Create lazy future (explicitly)
f <- lazy({
b <- 3
c <- 2
a * b * c
})
## Although 'f' is a _lazy_ future and therefore
## resolved/evaluates the future expression only
## when the value is requested, any global variables
## identified in the expression (here 'a') are
## "frozen" at the time point when the future is
## created. Because of this, the 'a' in the
## the future expression preserved the zero value
## although we reassign it in the global environment
a <- 7
print(a)
v <- value(f)
print(v)
stopifnot(v == 0)
Run the code above in your browser using DataLab