[Rd] S4 fails to initialize linear hierarchies with intermediate VIRTUAL classes

From: Martin Morgan <mtmorgan_at_fhcrc.org>
Date: Thu, 18 Oct 2012 06:31:44 -0700


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_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Thu 18 Oct 2012 - 13:34:52 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Fri 19 Oct 2012 - 00:00:48 GMT.

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

list of date sections of archive