Skip to content
Prev 6808 / 63421 Next

Should dots be used in generic functions?

Duncan Murdoch wrote:
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