[Rd] S4 'object is not subsettable' in prototype
Martin Maechler
maechler at stat.math.ethz.ch
Fri Aug 18 19:13:09 CEST 2006
>>>>> "Seth" == Seth Falcon <sfalcon at fhcrc.org>
>>>>> on Fri, 18 Aug 2006 09:54:54 -0700 writes:
Seth> Martin Maechler <maechler at stat.math.ethz.ch> writes:
>> 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.
Seth> I disagree with the notion that length and "[" should be tightly
Seth> coupled. An object having length doesn't have to mean that subsetting
Seth> makes any sense. For example, an environment has length, but what
Seth> should env1[1] return? And with S4 classes, there are many such
Seth> examples where "[i]" won't make sense.
You are right. I was rather thinking of "basic" objects
rather than highly structured objects such as S4 classes.
Note that for me, an environment belongs into the
category of "peculiar" exceptions ;-)
Martin
Seth> + seth
More information about the R-devel
mailing list