Chapter 9. Type System

9.1. Metatheory
9.2. Parametric Polymorphism
9.3. Subtyping
9.4. Adding Type Information
9.5. Type Override
9.6. Typing Contexts

The Orc language is dynamically typed. If an operation occurs at runtime which is not type correct, that operation halts silently, and reports an error on the console.

Orc also has an optional static typechecker, which will guarantee that a program is free of type errors before the program is run. For every expression in the program, the typechecker tries to find the types of values that the expression could publish, and then checks that all such types are consistent. The typechecker performs a limited form of type inference, so it can discover many of these types automatically. However, the programmer must provide additional type information for function definitions and for a few other specific cases.

The typechecker is disabled by default, though typed syntax is still permitted (and types are still checked for syntax errors) even when the typechecker is not used. It may be enabled as a project property in the Eclipse plugin, or by using the --typecheck switch on the command line.

If the typechecker can verify that a program is correctly typed, it will display the message

Program type checks as T

This means that the program has no type errors, and that every value published by the program will be of type T.