Skip to content

mget(missingArgument)?

2 messages · William Dunlap, Gabriel Becker

#
Currently, when mget() is used to get the value of a function's argument
with no default value and no value in the call it returns the empty name
(R_MissingArg).  Is that the right thing to do or should it return
'ifnotfound' or give an error?

E.g.,
mget(c("x","y","z"), envir=environment(), ifnotfound=666)})()
List of 3
 $ x: symbol
 $ y: chr "y from function's environment"
 $ z: num 666

The similar function get0() gives an error in that case.
Error in get0("x", envir = environment(), ifnotfound = 666) :
  argument "x" is missing, with no default

Bill Dunlap
TIBCO Software
wdunlap tibco.com
#
At first I thought this was more or less correct, because
[1] TRUE


reflects the actual "value" of x, but then at the very least this
*Error in f() : argument "y" is missing, with no default*


Is a problem because, of course, y was not an argument of f and talking
about its default is nonsensical, and the actual argument which was missing
is not named.


~G

On Mon, Jun 22, 2020 at 5:06 PM William Dunlap via R-devel <
r-devel at r-project.org> wrote: