[Rd] is(x, "parent") returns FALSE when class(x) is c("child", "parent") (PR#10549)
timh at insightful.com
timh at insightful.com
Mon Jan 7 20:30:23 CET 2008
In S-PLUS, is() does catch parent S3 classes. It does not
require a setOldClass definition to do so. I would prefer that
R work the same way, to make porting code easier.
I use is() in S-PLUS for both S3 and S4 classes because it is faster
than inherits(). I use inherits() only for testing a vector of
classes, rather than a single class.
To suggest that S3 has no class inheritance seems odd.
We use inheritance of S3 classes all the time - "ordered" inheriting
from "factor", many classes inheriting from "data.frame", etc.
I see no problem in having inheritance without class definitions.
>>>>>> "TimH" == timh <timh at insightful.com>
>>>>>> on Sat, 5 Jan 2008 02:05:08 +0100 (CET) writes:
>
> TimH> is() does not catch parent S3 classes:
>
> >> library(splines)
> >> temp <- bs(1:99, df=5)
> >> class(temp)
> TimH> [1] "bs" "basis"
> >> is(temp, "basis")
> TimH> [1] FALSE
>
> TimH> In contrast, is() does catch parent S4 classes:
>...
>
>Yes, that's all correct, but where's the bug?
>
>S3 has *NO* class definitions, so how can there be class
>inheritance?
>There's many reasons to go from S3 to S4, and the lack of class
>definitions in S3 is an important one...
>
>Now, still being curious: Are you implicitly saying that in S-plus,
>is() behaves differently, namely
>``as if S3 classes would exist?'' (:-)
More information about the R-devel
mailing list