5 Types and Classes
instance?(object, type)
tests type membership.
subtype?(type1, type2)
tests type inclusion.
make(type ...)
makes an instance. This operation is only supported if the type is instantiable.
==
.
The following is an informal description of type relationships: The function subtype?
defines a partial ordering of all types. Type t1 is a subtype of type t2 (i.e. subtype?(t1, t2)
is true) if it is impossible to encounter an object that is an instance of t1 but not an instance of t2. It follows that every type is a subtype of itself. Two types t1 and t2 are said to be equivalent types if subtype?(t1, t2)
and subtype?(t2, t1)
are both true. t1 is said to be a proper subtype of t2 if t1 is a subtype of t2 and t2 is not a subtype of t1.
subtype?
on classes is defined by inheritance. A class is a subtype of itself and of its general superclasses.
subtype?
on singletons is defined by object type and identity. If x is an object and t is a type, subtype?(singleton(x), t)
will be true only if instance?(x, t)
is true.
subtype?
rules for union types are given in "Union Types" on page 71. subtype?
rules for limited integer types are given in "Limited Integer Types" on page 72. subtype?
rules for limited collection types are given in "Limited Collection Types" on page 124.
<object>
is the root of the type hierarchy. All objects are instances of <object>
, and all types are subtypes of <object>
.
A number of operations on types are described in "Reflective Operations on Types" on page 329.
limited(C,
...)
is C.The type t1 is a pseudosubtype of the type t2 if t1 is a subtype of the base type of t2 and t1 and t2 are not disjoint.
Note that t1 being a subtype of t2 implies that t1 is a pseudosubtype of t2, but t1 being a pseudosubtype of t2 does not imply that t1 is a subtype of t2. Note also that if t2 is not a limited type or some other non-standard type, then pseudosubtype is the same as subtype.
Base types and pseudosubtypes are used in the rules for sealing, described in Chapter 9, "Sealing."
<collection>
and its element type is definite and not equivalent to the limited collection type's element type, or the class is a subclass of <collection>
and its element type is indefinite and not a supertype of the limited collection type's element type.
<collection>
and <integer>
are disjoint.)
#f
, or they are =
to each other, or one is a sequence of integers and the other is the product of those integers.
<integer>
whose range is disjoint from the limited integer type's range.
Generated with Harlequin WebMaker