[Rd] class() bug when used within a validity method

Pages, Herve hp@ge@ @end|ng |rom |redhutch@org
Tue Aug 20 01:31:13 CEST 2019


On 8/19/19 16:23, Pages, Herve wrote:
...
> Note that this doesn't happen if A is defined as a VIRTUAL class.

To be precise, when A is a VIRTUAL class, it requires at least
one additional level of class extension to break class():

   setClass("A", contains="VIRTUAL", slots=c(stuff="ANY"))
   setValidity("A", function(object) {
     cat("validating an object of class:", class(object), "\n")
     TRUE
   })
   setClass("B", contains="A")
   setClass("C", contains="B")

Then:

   c <- new("C")
   validObject(c)
   # validating an object of class: B
   # [1] TRUE

H.


-- 
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages using fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319


More information about the R-devel mailing list