futureverse / futureverse/progressr
Is it possible to support local(..., envir = environment())?
- Dominant language
- R
- Stars
- 299
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
```r
library(progressr)
handlers(global = TRUE)
xs <- 1:5
local(envir = environment(), {
p <- progressor(along = xs)
y <- lapply(xs, slow_sum)
})
```
gives
```
Error in progressor(along = xs) :
A progressor must not be created in the global environment unless wrapped in a with_progress()
or without_progress() call. Alternatively, create it inside a function or in a local() environment to
make sure there is a finite life span of the progressor
```
but it should be possible to support that, because:
```r
> local(envir = environment(), { on.exit(message("done")) })
done
```
BTW, we could even target:
```r
> local(envir = NULL, { x <- 42; on.exit(message("done")) })
done
> x
[1] 42
```
which is a tad easier to type;
```r
local(envir = NULL, {
p <- progressor(along = xs)
y <- lapply(xs, slow_sum)
})
```
or even
```r
local({
p <- progressor(along = xs)
y <- lapply(xs, slow_sum)
}, NULL)
```
Contributor guide
Assessment
This issue has not been assessed yet.