From wdunlap at tibco.com  Fri Apr 17 20:07:10 2009
From: wdunlap at tibco.com (William Dunlap)
Date: Fri, 17 Apr 2009 11:07:10 -0700
Subject: [Rd] some .Primitive's generate odd missing-argument messages
Message-ID: <77EB52C6DD32BA4D87471DCD70C8D7000107623C@NA-PA-VBE03.na.tibco.com>

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 



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