Skip to content

actual argument matching does not conform to the definition (PR#13634)

3 messages · Thomas Lumley, Wacek Kusnierczyk

#
Full_Name: Wacek Kusnierczyk
Version: 2.10.0 r48269
OS: Ubuntu 8.04 Linux 32 bit
Submission from: (NULL) (129.241.199.164)


In the following example (and many other cases):

   quote(a=1)
   # 1

the argument matching is apparently incorrect wrt. the documentation (The R
Language Definition, v 2.8.1, sec. 4.3.2, p. 23), which specifies the following
algorithm for argument matching:

1. Attempt to match named actual arguments to formal arguments exactly.
2. For the arguments remaining from step 1, attempt to match named actual
arguments to formal arguments partially.
3. For the arguments remaining from step 1, collectively match all unnamed
actual arguments to the formal argument '...', if available.
4. If any arguments remain, declare an error.

quote(a=1) qualifies for step 4:

1. The actual argument 'a' does not match exactly quote's only formal argument,
'expr'.
2. The actual argument 'a' does not match partially quote's only formal
argument, 'expr'.
3. quote has no formal argument '...', hence 'a' remains unmatched.
4. An error should be raised.

Instead, the actual argument 'a' is matched to the formal argument 'expr'.  This
clearly conflicts with the definition.  Either the definition or the
implementation (or both) are wrong.

The problem is not constrained to quote, and seems to be ubiquitous (though does
not apply to all functions).

There are additional minor issues with the documentation which were raised in a
separate thread.

Regards,
vQ
#
The explanation is that quote() is a primitive function and that the argument matching rules do not apply to primitives.  That section of the R Language definition should say that primitives are excluded;  it is documented in ?.Primitive.

     -thomas
On Thu, 2 Apr 2009 waku at idi.ntnu.no wrote:

            
Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle
#
Thomas Lumley wrote:
thanks.  indeed, the documentation --  the language *definition* --
should make this clear.  so this is a bug in the definition, which does
not match the implementation, which in turn is as intended (right?)

?.Primitive says:

"     The advantage of '.Primitive' over '.Internal' functions is the
     potential efficiency of argument passing.  However, this is done
     by ignoring argument names and using positional matching of
     arguments (unless arranged differently for specific primitives
     such as 'rep'), so this is discouraged for functions of more than
     one argument.
"

what is discouraged?

vQ