To take advantage of the information-hiding principle implies that type definitions are best separated from their implementations. Consequently Timor has two fundamental kinds of units: types and implementations. These replace the conventional classes of object oriented languages.
A Timor type definition is introduced by the keyword type. It does not contain code in the conventional sense but merely method headings. Ideally it would be good to extend these to formal specifications, but I have no time for that. Perhaps someone with an interest in formal specifications will help?
A type definition can contain various sections. An instance section contains definitions of instance methods. It can also have a protected section for methods which can only be called by implementations of derived types and co-types (see below). It can also have a callback section defining instance methods which can only be called from a module which itself was invoked directly from the current module.
A method header in a type definition must list in its heading all the exceptions which it explicitly throws, using the keyword throws. It can, but need not, define other exceptions (e.g. those of the methods which it invokes or arithmetic and other typical run-time exceptions). All exceptions are unchecked, in the sense of Java unchecked exceptions.
A type definition can include abstract variables, which the compiler treats as a "setter and getter" pair and provides a standard implementation, which can be overridden in an actual implementation.
The following keywords can precede the keyword type.
- a) abstract: indicates that an abstract type is being defined;
- b) singleton: in a module only one instance of the type can be created;
- c) library: the type can be implemented in SPEEDOS as a library module;
- d) comod: the type is implemented in SPEEDOS as a module which can accept
and return reference parameters;
- e) callback: the type must be implemented in SPEEDOS as a call back module.