[Rd] s4 methods and base

Paul Gilbert pgilbert at bank-banque-canada.ca
Tue Aug 12 14:02:56 MEST 2003


> But maintainers of software using S3 methods and classes
> might want to consider conversions or partial conversions, when and if
> they decide to revise the software.  

I'm curious about the logistics of a partial conversion. Initially I 
think I will avoid classes that inherit from other classes. But what 
general approach would you suggest for classes that have an object of 
another class in their structure. Can the larger object be an S4 class 
and the contained object an S3 class, or would you start the other way 
around, or is it not possible?

Also, would you suggest converting to namespaces before or after 
converting to S4 classes?

> With S4 classes, every object has a single class, with an explicit
> definition.  That class can have superclasses  (defined as the classes
> this class contains).

(newbie question) Are you using "contains" as a synonym for "extends," 
meaning that many classes can contain the same superclass, or is this 
intending to indicate that the logic is the reverse of (my understanding 
of) S3 logic?

>  - classes that don't have multiple strings in the class attribute can
> often just be converted to a non-virtual S4 class, so long as objects
> always have the same attributes.  Attributes go into slots (the slot
> must have some specified class, but there are ways to allow some
> variation in the actual type of data in the slot).

(newbie question) I often use attributes to stick "extra" information on 
an object, like the date of retrieval from a database onto a matrix. If 
the matrix is an S4 matrix class, does this mean that I have to define a 
new class in S4 that extends the matrix class in order to stick on extra 

Paul Gilbert

More information about the R-devel mailing list