[Rd] S4 'object is not subsettable' in prototype
Martin Maechler
maechler at stat.math.ethz.ch
Fri Aug 18 16:15:51 CEST 2006
>>>>> "Martin" == Martin Morgan <mtmorgan at fhcrc.org>
>>>>> on Thu, 17 Aug 2006 15:35:53 -0700 writes:
Martin> Extracting prototype structure apparently relies on list properties of
Martin> the earlier S4 implementation.
Martin> Martin
>> setClass("A", representation(x="numeric"))
Martin> [1] "A"
>> str(getClass("A"))
Martin> Formal class 'classRepresentation' [package "methods"] with 11 slots
Martin> ..@ slots :List of 1
Martin> .. ..$ x: atomic [1:1] numeric
Martin> .. .. ..- attr(*, "package")= chr "methods"
Martin> ..@ contains : list()
Martin> ..@ virtual : logi FALSE
Martin> ..@ prototype :Error in object[1:ile] : object is not subsettable
Thank you, Martin,
As you probably know, in R-devel, S4 objects have been changed "under
the hood" to finally have become ``first rate'' R entities;
and more changes are expected before release.
I agree you've found an "infelicity" in the current setup,
since
> setClass("A", representation(x="numeric"))
[1] "A"
> getClass("A")@prototype
<S4 Type Object>
attr(,"x")
numeric(0)
> length(getClass("A")@prototype)
[1] 1
> getClass("A")@prototype[1]
Error in getClass("A")@prototype[1] : object is not subsettable
>
It's not clear yet to me *what* should be changed.
For my taste, if length(object) returns 1,
I'd typically want that object[1] should be valid;
but I think we already have some (peculiar) exceptions to that
rule.
If you look at such prototypes for more complicated classes,
you get even more the impression that some bit (maybe
literally?) is missing somewhere.
Martin
More information about the R-devel
mailing list