[Rd] another S4 question ...
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Dec 11 18:11:06 CET 2007
Here is my current understanding: this area has changed a bit recently.
S4 generics of the same name in different packages are regarded as
different. If you define a generic show() in your package, it will not
have any of the methods defined on methods::show, and likely mask the
latter. So users will be asking 'where have all my show() methods gone?'.
Then there are the perennial scoping problems. If both your package and
methods have generics for show(), which is found depends on where you are
looking from: you cannot in general 'override' an existing function in
R's scoping system. For example, any function in another package that
imports 'methods' will find methods:::show and not your version.
This is a generic problem: e.g. both packages stats4 and lme4 have
generics for BIC, and you will get the methods for one or the other
depending on which is found first in the current scope.
On Mon, 10 Dec 2007, Ben Bolker wrote:
> The default generic method for "show" has arguments
> show(object) -- (no "...") -- which precludes any kind
> of arguments like "digits", etc.
You can define methods on print(), if you want those arguments.
> Is it impossible, or a horrible idea, to override the
> generic definition? (The "arm" package has defined a
> new generic, "display", which does a similar thing but
> has an intermediate level of detail (between "print/show"
> and "summary")
> Ben Bolker
Brian D. Ripley, ripley at 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 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel