When writing generic functions, should "..." arguments be routinely used? The Writing R Extensions manual says that if it is used, all descendant methods must use it too. In most cases in the R library source, the generic has the dots, often documented as parameters for the descendants (e.g. profile does this). In the case of profile, the descendants declare the dots, but don't make use of them. Duncan Murdoch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 18 Jan 2002, Duncan Murdoch wrote:> When writing generic functions, should "..." arguments be routinely > used? > > The Writing R Extensions manual says that if it is used, all > descendant methods must use it too. In most cases in the R library > source, the generic has the dots, often documented as parameters for > the descendants (e.g. profile does this). In the case of profile, the > descendants declare the dots, but don't make use of them.You mean the `methods' (they are not really descendants of anything)? If so, you can't tell, as anyone can write a method. In this case there are methods profile.nls and profile.glm, and they each have arguments that the generic and the other method does not have, so they do make use of the ... in the generic. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Duncan Murdoch wrote:> > When writing generic functions, should "..." arguments be routinely > used? > > The Writing R Extensions manual says that if it is used, all > descendant methods must use it too. In most cases in the R library > source, the generic has the dots, often documented as parameters for > the descendants (e.g. profile does this). In the case of profile, the > descendants declare the dots, but don't make use of them. > > Duncan Murdoch > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._A comment on this for the formal ("S4") methods, where a similar discussion came up. The concept we're developing is that the formal arguments of the generic function and each of its methods must "conform". This means that they should have identical arguments, with two exceptions: 1- the method can omit formal arguments from the generic, which is interpreted as identical to having the omitted arguments in the method signature with class "missing"; 2- the method can have arguments not in the generic if the generic has ..., with the interpretation that the actual arguments matching ... may correspond to the extra arguments. There are some additional constraints, such as consistent order of common arguments, to attempt to ensure sanity. The r-devel version of the methods package has both these extensions, the 1.4 version has the first (with a bug in handling ... that's fixed in r-patched). This somewhat extends the green book (and the current S-Plus implementation), but it seems to correspond to useful techniques for applications. I'm hopeful that we can iron out a good API, and then have both R and S-Plus implement it. John -- John M. Chambers jmc@bell-labs.com Bell Labs, Lucent Technologies office: (908)582-2681 700 Mountain Avenue, Room 2C-282 fax: (908)582-3340 Murray Hill, NJ 07974 web: http://www.cs.bell-labs.com/~jmc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
John Chambers wrote:> 2- the method can have arguments not in the generic if the generic has > ..., with the interpretation that the actual arguments matching ... may > correspond to the extra arguments.In this case, would the method have ... as well, or not? Paul Gilbert -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._