[Rd] some .Primitive's generate odd missing-argument messages

William Dunlap wdunlap at tibco.com
Fri Apr 17 20:07:10 CEST 2009


Since R 2.8.0 (and up to 2.10.0-devel, but not in 2.7.1),
if you call a function without a required argument and
the missing argument is first evaluated inside certain
.Primitive calls, then the error message about the missing
argument is different from the normal one and is harder
to understand.

E.g., sometimes you get 'element 1 is empty':
  > (function(x)x>0)()
  Error in (function(x) x > 0)() :
    element 1 is empty;
     the part of the args list of '>' being evaluated was:
     (x, 0)

and sometimes you get 'Non-numeric argument ...'
  > (function(qaz)log(qaz))()
  Error in log(qaz) : Non-numeric argument to mathematical function

and sometimes the missingness of the argument in the caller is
passed down to the callee:
  > (function(qaz,base)log(qaz,base))(qaz=10) # acts like base=exp(1)
  [1] 2.302585

Sometimes you get a direct message about the argument being missing:
  > (function(x)if(x) "yes" else "no")()
   Error in (function(x) if (x) "yes" else "no")() :
     argument "x" is missing, with no default

In 2.7.1 the missingness of the base= argument to log was passed
down, but the others gave the message "argument <x> is missing,
with no default".  The old uniform messsage made it easier to
track down problems.

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com 



More information about the R-devel mailing list