Open
Description
The future package saves output and warnings from code executed within futures and "replays" them when the future's value is requested. Note the order in which the messages and warnings appear in these examples:
library(future)
x <- future(message("Hello from the future!"))
message("Greetings from the present!")
#> Greetings from the present!
value(x)
#> Hello from the future!
invent_skynet <- function() {
message("Inventing Skynet...")
f <- future(warning("Killer robots from the future!"))
message("Finished inventing Skynet.")
return(f)
}
value(invent_skynet())
#> Inventing Skynet...
#> Finished inventing Skynet.
#> Warning in eval(quote(warning("Killer robots from the future!")), new.env()):
#> Killer robots from the future!
Created on 2021-04-26 by the reprex package (v2.0.0)
In theory, it should be equally possible to capture the standard output and standard error of each call to a memoised function and replay them each time the function is called with the same arguments. This could be useful for cases where a memoised function issues a warning, but that warning is not noticed on the first run. It would be nice if subsequent memoised calls to the same function could also produce the warning, to increase the chances that the user notices it.
Metadata
Metadata
Assignees
Labels
No labels