Type Equality



next up previous contents index
Next: Type Hierarchy Up: Types and Parameterized Previous: Type Designators

Type Equality

Type checking in Theta occurs at compile time and is based on analysis of type designators to determine whether they designate the same type. Two type designators are equal if the designate the same type and otherwise they are unequal.

Type equality is defined as follows:

  1. Each simple type is equal only to itself.

  2. Two types obtained by instantiation are equal if they are instantiations of the same (user-defined or built-in) parameterized type and their parameters are pairwise equal.

  3. Two routine types are equal if: both are proc or both are iter; both have the same number of arguments, and types of matching arguments are equal; both have the same number of results (yielded results for iterators), and the types of matching results are equal; both have the same exceptions, and matching exceptions have the same number and types of results.

  4. Two tagged types are equal if each has the same tagged_type, the same field names in the same order, and the type of matching field names are equal. E.g., these two types are not equal:
    record[a: int, b: int]
    record[b: int, a: int]



theta-questions@lcs.mit.edu