Programs



next up previous contents index
Next: Lexical Considerations Up: Overview of the Previous: Parametric Polymorphism

Programs

A Theta program consists of a group of _program_ _units_. A program unit is a specification (9), equate (4.6), or module (10.1). Specifications define abstract types and routines; modules provide implementations of these types and routines. Equates provide abbreviations for constants, e.g., the name "pi" might denote the number 3.1416.

Within program units, _external names_ (4.3) are used to refer to specifications and equates. External names can be chosen locally to fit the needs of the unit that uses them; this allows different units to define entities with the same name without causing a global name conflict. For example, two different specifications could both define a type named "int_set".

Theta compilers provide separate compilation for program units. The compiler makes use of the specifications denoted by external names of the unit being compiled to ensure that the type or routine is used in a type-correct manner. During the _linking_ process, an implementation is selected for each of these types and routines.

This manual does not define the mechanisms for interpreting external names during compilation and linking. A compiler might process a file containing many units such that every external name is defined somewhere in the file, and every specification in the file is implemented in some module in the file. Alternatively, objects recording the meanings of exported names might be stored persistently (_e.g._, in Thor); in this case the compiler might process an individual unit in a context that associates its external names with appropriate specification objects, and the linker might select routine implementations using a context that associates external names with appropriate implementation objects.


theta-questions@lcs.mit.edu