[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-help
Subject:    [R] S4 Method Dispatch for Sealed Classes
From:       "Thomas Koenig" <thomas.koenig () epigenomics ! com>
Date:       2006-08-31 16:36:57
Message-ID: 44F71029.404 () epigenomics ! com
[Download RAW message or body]

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@epigenomics.com

______________________________________________
R-help@stat.math.ethz.ch 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.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic