Supertypes
What supertypes are
If a type S is a supertype of type T, the basic attributes and methods
of type S can also be applied to objects of type T; and the semantics
of objects in type T is consistent with that of objects in type S.
We say that type T is a subtype of type S, and that objects of type T
(and of type S) conform to type S.
Subtyping is transitive. If type R is a subtype of type S, and type S
is a subtype of type T, then type R is a subtype of type T.
A type may have multiple supertypes.
How supertypes are defined
Many subtyping relations exist implicitly, but TOP will not
consider one type to be a subtype of another type unless the
supertype relation is explicitly declared in the description of
the subtype, or unless there is a chain of such declarations
leading from the subtype to the supertype.
Subtype declarations essentially make guarantees about the
behavior of the subtype. They may require some sort of explanation
or abstraction function showing how the subtype conforms to the
supertype. But new supertype declarations should not actually introduce
any new semantic constraints that weren't in the original definition
of the subtype. In order to prevent such constraints from being
spuriously introduced, TOP servers will often constrain who is
allowed to make new supertype declarations.
Supertypes and substitutability (some formal notes)
Those familiar with object type theory may recognize that
the notion of subtyping above is basically equivalent to some
formal notions of "substitutability". One should, however, note the
following differences between TOP's subtyping and the subtyping that
exists in some object-oriented systems that use substitutability:
- Since subtypes may be encoded completely differently from
supertypes, an object might not be "substitutable" (in the everyday
sense of the word) for an object in a supertype until a conversion
takes place.
- Since the TOP type system does not address object mutation,
certain kinds of subtypes are possible in TOP that aren't possible
in mutable object systems.
spok@cs.cmu.edu (Last updated 11-Jan-95)