Hi,
I encounter a problem with method dispatch with S4 classes, using the
'sealed' parameter in setClass.
See that example below:
setClass("X",representation(x="numeric"),sealed=TRUE)
setGeneric("foo",function(x) standardGeneric("foo"))
setMethod("foo",signature("X"),function(x)
print("foo(X)"))
x <- new("X")
foo(x) ## works fine
setClass("Y",representation("X"))
y <- new("Y")
foo(y) ## works fine
setClass("Z",representation("X"),sealed=TRUE)
z <- new("Z")
extends("Z")
## [1] "Z" "X"
foo(z) ## error
Error in foo(z) : no direct or inherited method for function 'foo' for
this call
My question is: why does sealed=TRUE impact on method dispatch?
Please, can you point me to the relevant documentation?
Reading ?setMethod, ?Methods, I failed to find an answer.
Thank you.
Best.
Thomas
Tried on R 2.3.1 and R 2.4.0-devel (2006-08-29 r39012): same result.
--
Thomas Koenig Biostatistician
Epigenomics AG Kleine Praesidentenstr. 1 10178 Berlin, Germany
phone:+49-30-24345-376 fax:+49-30-24345-555
http://www.epigenomics.com thomas.koenig at epigenomics.com
>>>>> "Thomas" == Thomas Koenig <thomas.koenig at epigenomics.com> >>>>> on 31 Aug 2006 18:36:57 +0200 writes:Thomas> I encounter a problem with method dispatch with S4 Thomas> classes, using the 'sealed' parameter in setClass. [...................] [...................] Thomas> Tried on R 2.3.1 and R 2.4.0-devel (2006-08-29 r39012): same result. Sorry for not being really helpful, but there have been substantial S4 related changes to R-devel since r39012 -- particularly about method dispatch. Could you also try to use last night's r39045 (or something newer)? There are several R developers who are really eager testing the new S4 code inside R-devel. For those R-help readers not subscribed to R-devel and interested it this: Please look at https://stat.ethz.ch/pipermail/r-devel/2006-August/039088.html and consider reading the "accompanying" paper by John Chambers "How S4 Methods Work" . Followups on this topic do rather belong to R-devel than R-help I think. Martin