Re: [R] Re: S4 method inheritance

From: Thomas Lumley <>
Date: Wed 25 May 2005 - 00:33:30 EST

On Mon, 23 May 2005, Ross Boylan wrote:

> On Mon, 2005-05-23 at 14:41 -0700, Ross Boylan wrote:
> ....
>> Finally, I'm a bit concerned that one article mentioned that S4
>> inheritance, in practice, is used mostly for data, not methods (Thomas
>> Lumley, R News 4(1), June 2004: p. 36). Am I going down a road I
>> shouldn't travel?
> Hmm, maybe I just found out. If B is an S4 subclass of A (aka extends
> A), how does B's method foo invoke A's foo?

You may be looking for callNextMethod, or foo(as(object, "A")).

The comment about inheritance in my R News article has nothing to do with S3 vs S4. It is just that extensions of data structures typically happen by specialisation (for which inheritance is appropriate) whereas models are typically extended by generalisation (for which inheritance isn't appropriate).

The only relevance to the S3 vs S4 discussion is that it provides an explanation for the lack of appreciation of S4. Since most statisticians don't use inheritance when programming they don't see the benefit in a system that gets inheritance right.

         -thomas mailing list PLEASE do read the posting guide! Received on Wed May 25 00:39:44 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:01 EST