These lines of code setClass("A", representation(x="numeric")) setMethod(initialize, "A", function(.Object, ...) stop("oops")) setClass("B", representation("A")) result in> setClass("B", representation("A"))Error in initialize(value, ...) : oops in R version 2.9.0 alpha (2009-03-28 r48239) R version 2.10.0 Under development (unstable) (2009-03-28 r48239) but not in r48182. In addition, in package code, the error above does NOT lead to removal of the partially installed package, or of the lock on the package directory, corrupting the user installation. For more context, the actual code adds arguments to initialize and expects them to be provided by calls to 'new'; 'new' is not exposed directly to the user but via a constructor that always provides appropriate arguments. A specific example occurs when trying to install the package Biostrings v 2.11.44 from the Bioconductor devel repository. Martin -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M2 B169 Phone: (206) 667-2793
It's the result of fixing a previous bug ( that Martin Maechler uncovered). Suppose that "A" was on another package. Then the result of as(new("B"), "A") had the wrong package in its class. The construction of the as() method stored in the "contains" slot of class "B" will generate an object from "A" in order to get the correct class to assign when coercing to "A". The relevant code in methods:::.simpleCoerceExpr in RClassUtils.R is: if(!isVirtualClass(toDef)) toClass <- class(new(toDef)) # get it with the package slot correct (Of course this is only done once) John Martin Morgan wrote:> These lines of code > > setClass("A", representation(x="numeric")) > setMethod(initialize, "A", function(.Object, ...) stop("oops")) > setClass("B", representation("A")) > > result in > > >> setClass("B", representation("A")) >> > Error in initialize(value, ...) : oops > > in > > R version 2.9.0 alpha (2009-03-28 r48239) > R version 2.10.0 Under development (unstable) (2009-03-28 r48239) > > but not in r48182. > > In addition, in package code, the error above does NOT lead to removal > of the partially installed package, or of the lock on the package > directory, corrupting the user installation. > > For more context, the actual code adds arguments to initialize and > expects them to be provided by calls to 'new'; 'new' is not exposed > directly to the user but via a constructor that always provides > appropriate arguments. A specific example occurs when trying to > install the package Biostrings v 2.11.44 from the Bioconductor devel > repository. > > Martin >[[alternative HTML version deleted]]