-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy futures: Specify how/when globals are resolved? #1
Comments
Will hold this one of for a while, because if introduced it would also add dependency on |
Some arguments for having 'future' handle globals too: Mandelbrot demo> plan(lazy)
> demo('mandelbrot', package='future') will calculate convergence counts for the exact same (=the last one) complex plane for all iterations, because the globals are only resolved when evaluated. Globals needs to be "frozen" (exported) for each future. Fibonacci seriesThe following example for illustrating futures, does not work with current "lazy" implementation, because all future iterations end up using the same value on iterator variable > library("future")
> library("listenv")
> plan(lazy)
> f <- listenv()
> f[[1]] <- 0
> f[[2]] <- 1
> for (i in 3:50) f[[i]] %<=% { f[[i-2]] + f[[i-1]] }
> f[[4]]
Error in get(var, envir = x, inherits = FALSE) :
promise already under evaluation: recursive default argument reference or earlier problems? |
See commit f65a767. Added This only provides a mechanism for including ("freezing") globals for lazy future, and eager futures don't need it. If it turns out it is useful to provide an automatic mechanism for this in |
Background / current status
Proposal
Should there be an option to specify when globals in lazy futures should be resolved, e.g.
versus (current):
The purpose of this would mostly be to (i) illustrate the importance of understanding how globals are handled, and (ii) provide a lazy future mechanism that as far as possible emulated what happens when evaluating futures in external processes/R sessions.
To add this, we also need to add dependency on the globals package.
The text was updated successfully, but these errors were encountered: