Re: [R] inheritence in S4

From: <>
Date: Mon, 24 Mar 2008 18:32:34 +0100

> 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.



Ce message a ete envoye par IMP, grace a l'Universite Paris 10 Nanterre mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Mon 24 Mar 2008 - 17:41:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 24 Mar 2008 - 18:30:24 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive