Should dots be used in generic functions?
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._