Re: [R] inheritence in S4

From: <cgenolin_at_u-paris10.fr>
Date: Mon, 24 Mar 2008 10:42:04 +0100

Hi Martin

I am re reading all the mail we exchange with new eyes because of all the thing I learn in the past few weeks. That very interesting and some new question occurs...



Once, you speak about callGeneric :

setClass("A", representation(x="numeric")) setClass("C", contains=c("A"))

setMethod("show", "A", function(object) cat("A\n")) setMethod("show", "C", function(object) {

   callGeneric(as(object, "A"))
   cat("C\n")
})

new("C")

Considere the following definition (that you more or less teach me with your yesterday remarques...) :

setMethod("show", "C", function(object) {

   callNextMethod()
   cat("C\n")

})

In this case, is there any difference between the former and the latter ? Which one would you use ?

(I get that in more complicate case, for example if setClass("C", contains=c("A","B")), it might be more complicate to use the latter, right ?)



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



showMethods gives the list of all the method. Is there a way to see all the method for a specific signature IN THE ORDER they will be call by callNextMethod ?
If ANY <- D <- E, a method that will gives :

Function "initialize":
.Object = "E"
.Object = "D"

.Object = "ANY"

Thanks for your help
And happy easter eggs !

Christophe



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


R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 24 Mar 2008 - 09:48:06 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 - 17:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive