72 Subtypes of abstract types
Abstract types provide a basis for open variants, because concrete types may declare themselves to be subtypes of an abstract type.
A subtype is declared using isa with a non-empty list of supertypes. For example:
value Circle isa Shape
{
Point centre;
Real radius;
→ perimeter = 2 * pi * radius;
→ area = pi * radius * radius;
}
A value type cannot subtype an entity type, and an entity type cannot subtype a value type.
A subtype inherits the predicates of its supertypes and may define additional structure.
An existing concrete type may be declared a subtype of an abstract type after its definition, even in a different component:
// Component A
value Polygon
{
Point vertex*;
}
// Component B
abstract value Shape {};
// Component C, with dependencies on A and B
using A { Polygon };
using B { Shape };
Polygon isa Shape;