[Rd] S4 Classes

Martin Morgan mtmorgan at fhcrc.org
Fri Aug 11 05:22:45 CEST 2006


Gordon Smyth <smyth at wehi.EDU.AU> writes:

> Is there a capability that you would like for the package which could 
> be achieved only if the package was transitioned to S4? If so, 
> explain this to the author. If not, why ask them to change?

'achieved only if' sounds a bit strong. I've used S4 objects and found
them useful for, among other things:

* familiar object-oriented reasons (e.g., data structure and code
  reuse in derived classes and methods),

* flexibility over S3 classes (e.g., slot and validity checking to at
  least partly relieve me of the checks, familiar to S3 programmers,
  at the top of each function to ensure that the data conforms to
  expectation) and methods (e.g., dispatch on other than the first
  argument),

* interoperability with other packages,

* object introspection, e.g., validating and updating serialized
  objects against current class definitions, exchanging complicated
  data structures with other languages,

* the greater structure S4 classes and methods encourage in
  complicated programs, and

* fun challenges to exploiting the unique (relative to, say, Java)
  features of S4 class structure and method dispatch.

As Gordon says, though, package requirements should drive
implementation decisions.

Martin
--
Bioconductor

> Gordon
>
>>[Rd] S4 Classes
>>Daniel Gerlanc dgerlanc at gmail.com
>>Thu Aug 10 23:37:15 CEST 2006
>>
>>Hello All,
>>
>>I'm trying to convince someone that they should transition a large project
>>to use S4 instead of S3 classes.  Does anyone have any good citations?
>>Thanks!
>>
>>-- Dan Gerlanc
>>
>>--
>>Daniel Gerlanc
>>Williams College '07
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list