[Rd] FR: names= argument for load()
Michael Chirico
ch|r|com @end|ng |rom goog|e@com
Tue Feb 28 19:51:30 CET 2023
I have three use cases in mind for an argument to load specifying
which variables to load from the input 'file':
1. Avoid overwriting existing variables. ?load recommends using envir=
or attach() to avoid overwrites. An argument like names= would allow
even finer control to avoid collisions.
2. Avoid loading too many (in quantity or in memory size) variables
from a large file. We might save dozens or hundreds of models to the
same file and then load them more lazily.
3. Helping static analysis. Currently, when load() is used in a
script, it becomes impossible to distinguish truly undefined variables
from those defined implicitly by load(). With a names= argument, it
can be possible to know statically precisely which names were
introduced by load, and which might be a bug. (of course there's
nothing stopping authors from having non-literal entries to names=,
but that's a more general issue of static analysis).
Michael Chirico
More information about the R-devel
mailing list