Citing Joe Cheng, our aim is to:
- Execute long-running code asynchronously on separate thread.
- Be able to do something with the result (if success) or error (if failure), when the task completes, back on the main R thread.
A promise object represents the eventual result of an async task. A promise is an R6 object that knows:
Whether the task is running, succeeded, or failed
The result (if succeeded) or error (if failed)
This looks pretty exciting. H/T R-Bloggers
Every argument you pass to a function is a promise until the moment R evaluates it. Consider a function g with arguments x and y. Let’s leave out one argument in the function call:
g <- function(x, y) x g(1) ##  1
R will be forgiving (lazy) until the argument y is actually needed. Until then y exists in the environment of the function call as a ‘name without a value’. Only when R needs to evaluate y a value is searched for. This means that we can pass some non-existent objects as arguments to the function g and R won’t care until the argument is needed in the functions body.
Read the whole thing. Once again, H/T R-Bloggers