[Rd] S4 method and S3 method with same name: potentially dangerous?

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Jul 3 17:31:12 MEST 2003


I think you have `method' confused with `generic'.  predict() is an S3
generic, and you can safely allow that to be made into an S4 generic
(although there will be a small performance hit).  I would suggest that
you add S4 methods to show() and not to print(), though.


On Thu, 3 Jul 2003, Matthias Burger wrote:

> yet another question on S4 method behaviour or rather its side effects:
> Consider the following example (see below) where a new S4 method 'predict' is 
> defined which by doing so makes 'predict' a S4 standardGeneric.
> It works and simple test examples run but I'm cautious whether this is a 'silly' 
> thing to do.
> 
> Is this a dangerous thing to do, already known to break existing code, or
> cause unwanted side effects on the new S4 method?
> 
> Or can I savely make use of existing S3 methods with their clear and descriptive
> names and define new S4 methods with the same name?
> 


-- 
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 mailing list