C2 is defined to be a simple extension of a
class C1 if the two classes are related by a simple
setIs call:
setIs(C2, C1)
Simple extensions happen in two ways:
C1 being included in the
representation of C2, in which case no
explicit call to setIs is needed;
setIs, in which case
C1 must either be a virtual class or included
in C2 (in the sense of both having the same
definition for all the slots of C1).
In the current version of R (1.5.0 and later), simple extensions are
used in formal method dispatch without transforming the actual
argument.
That is, if a method exists corresponding to class C1
for some argument, and the actual argument has class
C2, then the method can be selected. If it is, the
method will be called with an untransformed argument (still class
C2, not the defined class).
We are considering applying the same convention to slot assignments.
Suppose a slot is assigned, say
If the slot was defined to have class
z@type <- x
C1 and
x has class C2, the assignment would
succeed and x would be stored in the slot, untransformed.
The same rule would apply to named arguments supplied to the function
new, assuming the class had no special
initialize method defined.
There are a few details to note:
setIs, because otherwise the two class
representations conflict, so a coerce= argument
must be supplied to setIs.