Skip to content
Prev 9171 / 63421 Next

[S] Old style and new style classes

On Tue, 1 Apr 2003 14:33:39 +0100
Jonathan Swinton <jswinton@proteom.com> wrote:

            
Jonathan,

I think you are asking the right questions.  SV4 has caused severe problems in S-Plus mainly due to lack of multiple inheritance.  I have been burned MANY times when running an object through a method (e.g., imputation) that sticks on an additional class.  Right now I am teaching a class using S-Plus 6 with my impute function in the Hmisc library and strange error messages are driving the students crazy.  So far all my tests in the R 1.7 development version indicate that R, unlike S-Plus, is backward compatible with old-style classes and methods.  But if you want to be compatible with S-Plus it would be nice if we could just avoid new classes and methods.  Unfortunately S-Plus does not let us do that either, because multiple old-style classes is not allowed any more.  

In the bigger picture,  I am still not really convinced that new classes and methods offer advantages to data analysts.  The new methods are not as flexible and take longer to program.  I frequently stick on a new element of a fit object list for debugging or for enhancing functions that others wrote.  You can't really do this with SV4.  Also, new methods and classes have made some code non-transportable across systems (primarily to older versions of S-Plus).  There are now packages on CRAN that use slots to address elements while other versions of these same packages use list elements.  Hence some code retrieves details of fit objects using @ and some needs to use $.  I know that retrieving pieces of fit objects is inelegant (extractor methods should be written) but it is very common that I don't want to take the time to write an extractor method for every application, and I sure hate to waste time sensing whether the object was created using old vs. new style classes.

I know that new classes and methods are more elegant from a computer science perspective, but I analyze data and like to use what works (e.g., I really like both Perl and Python).  New methods provide much more safety.  I have found though that I don't need this kind of protection from myself.  I have plenty of other problems to worry about.

That's my $.02 worth.