Skip to content
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

Passing .options causes eager evaluation of all arguments in foreach() #41

Open
mikmart opened this issue May 19, 2023 · 0 comments · May be fixed by #42
Open

Passing .options causes eager evaluation of all arguments in foreach() #41

mikmart opened this issue May 19, 2023 · 0 comments · May be fixed by #42

Comments

@mikmart
Copy link

mikmart commented May 19, 2023

Passing any .options causes all arguments to foreach() to be evaluated eagerly in a context where that may not be appropriate:

library(foreach)
foreach(i = 1:3) %:% foreach(j = i:3, .options.foo = "bar") %do% seq(i, j) |> str()
#> Error in eval(expr, envir, enclos): object 'i' not found
# Expected result
foreach(i = 1:3) %:% foreach(j = i:3) %do% seq(i, j) |> str()
#> List of 3
#>  $ :List of 3
#>   ..$ : int 1
#>   ..$ : int [1:2] 1 2
#>   ..$ : int [1:3] 1 2 3
#>  $ :List of 2
#>   ..$ : int 2
#>   ..$ : int [1:2] 2 3
#>  $ :List of 1
#>   ..$ : int 3

Discovered via this StackOverflow question: https://stackoverflow.com/q/76291120/4550695

@mikmart mikmart linked a pull request May 19, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant