From ripley at stats.ox.ac.uk  Tue Dec 11 18:11:06 2007
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue, 11 Dec 2007 17:11:06 +0000 (GMT)
Subject: [Rd] another S4 question ...
In-Reply-To: <475DB76E.5060503@zoo.ufl.edu>
References: <475DB76E.5060503@zoo.ufl.edu>
Message-ID: <Pine.LNX.4.64.0712110842150.10434@gannet.stats.ox.ac.uk>

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



[Rd] another S4 question ...
Prof Brian Ripley