From fparlamis at mac.com  Fri Oct 20 11:24:42 2006
From: fparlamis at mac.com (Parlamis Franklin)
Date: Thu, 19 Oct 2006 23:24:42 -1000
Subject: [Rd] understanding virtual classes and extensions thereof
Message-ID: <060DBDD8-C750-4BCE-BB58-FF71D1BDFA28@mac.com>

I am having some trouble creating a hierarchy of virtual classes  
(akin to the class structure in the 'Matrix' package).  I think they  
arise from my not understanding the best way to specify virtual  
subclasses of a virtual class.  please see questions below code.

setClass("mom")

setClass("kid1", representation("mom", "VIRTUAL"))
setClass("kid2", representation("VIRTUAL"), contains = "mom")
setClass("kid3"); setIs("kid3", "mom")

(i) Are 'kid1' and 'kid2' equivalent?  I.e., is there any difference  
between including a superclass as an unnamed argument in the  
'representation' call and including it in the 'contains' argument?   
If not, why does the 'contains' argument exist?

(ii) What is the difference between 'kid1' and 'kid2', on the one  
hand, and 'kid3', on the other hand?  I see that 'kid1' and 'kid2'  
have prototypes of class 'S4', while 'kid3' has a prototype of class  
"NULL".  But I don't really understand the implications of that.  I  
am using virtual classes mostly to economize on method writing.  Will  
it matter on any level whether my virtual classes have NULL or S4  
prototypes?

On a related note, the behavior exhibited below also seems infelicitous

setClass("kid4", contains = "mom")
new("kid4")  # error in the show method

franklin parlamis




[Rd] understanding virtual classes and extensions thereof
Parlamis Franklin