Built-in Types



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

Built-in Types

The built-in types are "null", "any", "bool", "char", "int", "real", "string", and all routine types. The built-in parameterized types are "array", "sequence", "vector", "record", "struct", "oneof", and "maybe".

The type "any" has no methods and is used as the top of the type hierarchy (3.4): all types, both built-in and user-defined, are subtypes of type "any".

The type "null" has one literal, "nil"; it is typically used as a placeholder in "oneof" types. The type "bool" is a conventional Boolean type, with literals "true" and "false". The type "int" represents a subrange of the mathematical integers, and the type "real" represents a finite-precision approximation to a subrange of the mathematical real numbers. The type "char" represents characters (typically ASCII), and the type "string" represents strings of characters (again, typically ASCII).

The parameterized types "array", "vector", and "sequence" are homogeneous collections indexed by consecutive integers. "Array" and "vector" are mutable types; a vector has a fixed size, while an array can grow and shrink dynamically. "Sequence" is an immutable type. The special types "record" and "struct" are heterogeneous tuples with names as selectors of fields; "record" is a mutable type, while "struct" is immutable. The special type "oneof" is a named, immutable, discriminated union. The parameterized type "maybe" is a special case of "oneof" which is used to represent an object that contains either an object of the parameter type, or the value "nil".

Routine types are also built-in types in Theta. Routines (i.e., the objects of these types) are defined by routine specifications (9) and routine implementations (10). Routines are first-class objects that can be stored in data structures and passed as arguments and results.

The full specifications of the built-in types appear in Appendix B. Every Theta implementation will provide implementations of these types. Appendix C contains specifications of some additional types that will be provided by most Theta implementations.



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



theta-questions@lcs.mit.edu