waku at idi.ntnu.no
2009-Apr-02 09:20 UTC
[Rd] actual argument matching does not conform to the definition (PR#13634)
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
Thomas Lumley
2009-Apr-02 12:39 UTC
[Rd] actual argument matching does not conform to the definition (PR#13634)
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:> 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 > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle
maechler at stat.math.ethz.ch
2009-Apr-03 13:20 UTC
[Rd] actual argument matching does not conform to the definition (PR#13634)
>>>>> "vQ" == Wacek Kusnierczyk <Waclaw.Marcin.Kusnierczyk at idi.ntnu.no> >>>>> on Thu, 02 Apr 2009 15:25:14 +0200 writes:vQ> Thomas Lumley wrote: >> >> 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. vQ> thanks. indeed, the documentation -- the language *definition* -- vQ> should make this clear. so this is a bug in the definition, which does vQ> not match the implementation, which in turn is as intended (right?) vQ> ?.Primitive says: vQ> " The advantage of '.Primitive' over '.Internal' functions is the vQ> potential efficiency of argument passing. However, this is done vQ> by ignoring argument names and using positional matching of vQ> arguments (unless arranged differently for specific primitives vQ> such as 'rep'), so this is discouraged for functions of more than vQ> one argument. vQ> " vQ> what is discouraged? Well... Wacek, as seem to you want it, and it being Friday afternoon... here comes .... a biased view of one R hobby historian : Even though R was created originally in New Zealand and then heavily picked up in Europe slightly before (North) America, the development model of R, in my eyes, has been closer to sentiments of people from the land of the free and home of the brave, rather than European censorship and dictatorship {being a full-hearted European, I hope I'm allowed the slight exaggeration ;-)}. Consequently, there has always been quite a bit of freedom in R development within the R core development team... and yes, R is not the result of comittee design-process, but yes, it's good we have members in the core team (and the wider R developer base) who have called us to make decisions and try to stand by them .. ;-) :-) The frequent vs minimal use of .Primitives has been one of the areas where some R-core members have tried to discourage other R-core members from "doing too much" .. Fact is that using *more* .Primitives rather than less during the last few years has allowed to make S3 and S4 method dispatch slightly more uniform and still efficient. In the long term, ideally we'd diminuish the number of .Primitives substantially, exactly for reasons some of which you mention in this thread. Martin