Ptolemy II Type System

Ptolemy II has a sophisticated type system that supports extensive polymorphism. The basis for the type system is a complete partial order (CPO) representing the relationships between types. The ordering relationship is one of lossless convertibility. I.e., type a is less than type b if an instance of type a can be converted losslessly to an instance of type b. For example, type IntToken is less than type DoubleToken which is less than ComplexToken. However, BooleanToken is incomparable to all of these (it is neither less than nor greater than them). A lesser type is more specific than a greater type, or a greater type is more general. Type constraints in an actor are specified as inequalities with respect to this CPO. Thus, for example, an actor may declare that its output type is at least the type of one of its parameters. The type resolution mechanism finds the least types (the most specific types) in the CPO that satisfy all the constraints.