From ripley at stats.ox.ac.uk  Wed Aug  6 10:02:30 2003
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed Aug  6 10:02:39 2003
Subject: [Rd] s4 methods and base
In-Reply-To: <8CBAA121CEB4D5118CB200508BB2BBEF0317E8F6@xmx8lonib.lonib.commerzbank.com>
Message-ID: <Pine.LNX.4.44.0308060849570.12351-100000@gannet.stats>

On Wed, 6 Aug 2003, Marsland, John wrote:

> This is the inconsistency I am talking about:
> 
> > getClass("POSIXt")

That is an inappropriate use of getClass with S3 classes.  It's perhaps an 
inconsistency in the methods package, but it is not in base.

> Virtual Class
> 
> No Slots, prototype of class "NULL"
> 
> Extends: 
> Class "POSIXct", directly
> Class "oldClass", by class "POSIXct"
> > getClass("POSIXct")
> Virtual Class
> 
> No Slots, prototype of class "NULL"
> 
> Extends: "oldClass"
> 
> Known Subclasses: "POSIXt"
> > getClass("POSIXlt")
> Error in getClass("POSIXlt") : "POSIXlt" is not a defined class
> 
> But to quote from the online help:
> 
> "POSIXct" is more convenient for including in data frames, and "POSIXlt" is
> closer to human-readable forms. A virtual class "POSIXt" inherits from both
> of the classes: it is used to allow operations such as subtraction to mix
> the two classes. 

POSIXt is not an S4 class, and that was written before there were S4
classes in R. 

> In a S4 world wouldn't make more sense for POSIXt to be a virtual superclass
> and POSIXct and POSIXlt to be subclasses?

Well, I would have preferred class = c("POSIXct", "POSIXt"), but it was
not possible to add POSIXt that way (it was not in the first released
implementation).  Changing S4 classes is a nightmare, BTW.


As I said before, please do learn the difference between S3 and S4
classes, and that `class' and `method' (unqualified) normally mean S3.

-- 
Brian D. Ripley,                  ripley@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] s4 methods and base
Prof Brian Ripley