Initialization of this simple hierarchy

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

fails (neat that setClass returns generators; I hadn't realized that before!)

> C(A())
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

because in the default coerce<-,C,A-method

> selectMethod("coerce<-", c("C", "A"))
Method Definition:

function (from, to = "A", value)
{
    .value <- as(from, "B", TRUE)
    as(.value, "A") <- value
...

as(from, "B", TRUE) correctly returns an instance of C.

Also VIRTUAL isn't mentioned on ?Classes or ?setClass and isn't documented on class?VIRTUAL, making me wonder whether virtual classes are actually meant to be supported as part of S4 (they are used regularly in Bioconductor packages)?

Martin
--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to