# NOT RUN {
lazy_(quote(a + x), globalenv())
# Lazy is designed to be used inside a function - you should
# give it the name of a function argument (a promise)
f <- function(x = b - a) {
lazy(x)
}
f()
f(a + b / c)
# Lazy also works when called from the global environment. This makes
# easy to play with interactively.
lazy(a + b / c)
# By default, lazy will climb all the way back to the initial promise
# This is handy if you have if you have nested functions:
g <- function(y) f(y)
h <- function(z) g(z)
f(a + b)
g(a + b)
h(a + b)
# To avoid this behavour, set .follow_symbols = FALSE
# See vignette("chained-promises") for details
# }
Run the code above in your browser using DataLab