[Rd] Inherited S4 .Data prototype not assigned

From: Martin Morgan <mtmorgan_at_fhcrc.org>
Date: Thu, 03 May 2007 12:56:06 -0700

An S4 class inheriting from another class with a prototype does not inherit (at least sometimes) the prototype for .Data:

> setClass("A", "numeric", 1)
> setClass("B", "A")
> new("A")

An object of class "A"
[1] 1
> new("B")

An object of class "B"

My expectation is that prototype inheritance of .Data behaves as for regular slots:

> setClass("A",

+          representation=representation(x="numeric"),
+          prototype=prototype(x=1))

[1] "A"
> setClass("B", "A")

[1] "B"
> new("B")

An object of class "B"
Slot "x":
[1] 1

I think this traces first to an errant ! that claims the data part is filled, when it is not yet, and second to a call to getDataPart with a primitive that occupies, but does not have, a .Data slot.



attached base packages:

[1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"  
[7] "base"     

Martin Morgan
Bioconductor / Computational Biology

R-devel_at_r-project.org mailing list
Received on Thu 03 May 2007 - 20:26:52 GMT

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 04 May 2007 - 01:35:21 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.