[Rd] S4 setMethod, setGeneric and default arguments

Martin Morgan mtmorgan at fhcrc.org
Mon Nov 22 17:34:28 CET 2010

On 11/22/2010 03:23 AM, evilphil wrote:
> <BUMP>
> anyone?

Hi evilphil --

Your method signature doesn't have 'missing' for its third argument, and
hence isn't the target of dispatch when the generic is invoked with a
missing argument. I guess you'd figured that out and are really asking
whether it's consistent with the S4 design, and I think it is.

Why one might provide a default to an argument that is also dispatched
on seems like a design decision on your part. Maybe because missing
argument dispatch is a common (default) use case? Or to advertise via
the generic args what a typical value might be? But dispatch on multiple
arguments becomes complicated -- the number of combinations of possible
arguments is large, the 'next' method very difficult to reason about --
so might best be avoided if not necessary. The 'signature' argument of
setGeneric allows arguments to be included but not dispatched on.

Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

More information about the R-devel mailing list