[R] please write unregister_scalar_function and/or make registration local/temporary
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the enhancement requested
The current mechanism for `register_scalar_function` is solely by side-effect, and keeping them around in the global environment can affect other uses of lazy operations.
I suspect that its "global" side-effect use is fine for most, since a lazy object can be realized/collected at any point, and the registered function must exist when collected. I suggest that this risk can be mitigated with the assumption that de-registration must be after collection.
This might be as simple as what I hope would happen with the following, without the error:
```r
register_scalar_function("arrow_dirname", function(context, z) dirname(z), in_type=string(), out_type=string())
environment(register_scalar_function)$.cache$functions$arrow_dirname
# function (...)
# Expression$create("arrow_dirname", ...)
#
environment(register_scalar_function)$.cache$functions$arrow_dirname <- NULL
# Error in loadNamespace(x) : there is no package called ‘*tmp*’
```
### Component(s)
R
Contributor guide
Assessment
This issue has not been assessed yet.