Types and Parameterized Types



next up previous contents index
Next: Built-in Types Up: No Title Previous: Operators and Punctuation

Types and Parameterized Types

A _type_ consists of a set of _objects_, along with a collection of _methods_ that belong to each of these objects. A method can access and manipulate its object's state. If none of an object's methods modify its _abstract state_ (the state that can be observed using its methods), we say the object is _immutable_; otherwise it is _mutable_. We say a type is immutable (mutable) if its objects are immutable (mutable).

A parameterized type defines a family of related types. For example, the "array" parameterized type defines the types "array[int]", "array[char]", "array[array[int]]", and so on. Each type in the family is obtained by _instantiating_ the parameterized type (3.2.2), producing a type referred to as an _instantiation_.

Theta has a number of built-in types and parameterized types. In addition, users can define new abstract types and parameterized types (9,10).

Theta has strong static type checking. Types are arranged in a type hierarchy: a type can be a subtype of several other types (3.4). The hierarchy for the built-in types is quite flat (3.4), except that there is a rich hierarchy for routine types (3.4.1). Users define the hierarchy for the user-defined types (9.2). The type hierarchy determines the legality of assignment (5) and invocation (6.1).

A type designator denotes a type. For example, a type designator can be the name of an ordinary type ("int", "color"), or an instantiation of a parameterized type ("array[int]", "maybe[employee]").

The Theta compiler requires complete information about the type denote by a type designator. For example it needs to know all methods of the type and their signatures, and also all supertypes of the type. This means that any identifiers used as type designators must either be defined in the current program unit or in the external compilation environment. If the designator denotes a user-defined type, all supertypes of the type must also be defined either locally or externally.





next up previous contents index
Next: Built-in Types Up: No Title Previous: Operators and Punctuation



theta-questions@lcs.mit.edu