[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"
numeric(0)

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.

Martin

locale:
LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=en_US;LC_MONETARY=en_US;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C

attached base packages:

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

-- 
Martin Morgan
Bioconductor / Computational Biology
http://bioconductor.org

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
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.