[R] inheritence in S4

cgenolin at u-paris10.fr cgenolin at u-paris10.fr
Mon Mar 24 18:32:34 CET 2008


> callGeneric is an advanced topic.

Ok, when I will be older :-)

>> *************************
>> This works :
>>
>> setMethod("initialize","B",
>>          function(.Object,..., yValue){
>>              callNextMethod(.Object, ..., y=yValue)
>>              return(.Object)
>>          })
>> new("B",yValue=3)
>>
>> but this does not :
>>
>> setMethod("initialize","B",
>>          function(.Object, yValue){
>>              callNextMethod(.Object, y=yValue)
>>              return(.Object)
>>          })
>> new("B",yValue=3)
>>
>> Why ?
>> Is there any help page about ... ?
>
> Both 'work' in the sense that an object is returned

Well yes, but the second one does return an object without assigning 
the value 3, that is not realy working...


> In an object-oriented sense, initialize,B-method should really just 
> deal with it's own slots; it shouldn't have to 'know' about either 
> classes that it extends (A) or classes that extend it. And it 
> shouldn't do work that inherited methods (i.e., 
> initialize,ANY-method) do.

I get your point and I agree : I am developing B, you are developing A, 
I do not want to know what is in A so B should not initialize its 'A 
part'

On the other hand, I do not like the "..." . "..." can be anything, 
there is no controle at all, no type checking.
I would prefers to initialize B giving its value for its own slot AND 
an object class A. So I send you the value for A, you send me an objets 
'aaa' of class A then I initialize B with some value and aaa. This way, 
B keep its role but does not transmit anythink to A without controling 
it.

Best,

Christophe

----------------------------------------------------------------
Ce message a ete envoye par IMP, grace a l'Universite Paris 10 Nanterre



More information about the R-help mailing list