Modes

Instances of objects created from types/implementations in Timor can be created and used at three different levels.

  • Persistent file objects (which correspond to files in other systems) are instantiations of types with an information hiding interface. These are visible at the operating system level and are accessible via special pointer variables (directly supported in the SPEEDOS environment) known as capabilities. Within a Timor program a capability is characterised by a two-star notation. For example if a type Index is instantiated as a file, capabilities for it are referred to in Timor as Index**, where Index is the type and ** indicates that the mode is a capability for a persistent file object.
  • Local objects within a persistent file (which are therefore also persistent) correspond loosely to various units within conventional programming languages. These are accessible via pointer variables (which are usually invisible at the operating system level) called references and use a one-star notation. For example if the type Index is instantiated as a local (within file) object, references for it are referred to in Timor as Index*, where * indicates that the mode is a reference for a local object.
  • Finally types can be instantiated as value variables within local objects. In this case the star notation is not used.

At all levels the information hiding principle is strictly preserved, i.e. the internals of a file object (e.g. its local objects) are not visible from another file; they can only be accessed indirectly by the file's interface methods. Similarly the internals of a local object (e.g. its values) are not directly visible to other local objects, and can only be accessed via the interface methods of the local object.

Constructors always return a value instance. This can be converted into a local object by applying the new operator, or it can be converted into a persistent file by applying the create operator.

Sometimes it can be useful (especially – but not only – in method parameters) to pass an instance of a type where knowledge of the actual mode is not fixed. This is achieved using parameters/variables with a three star notation (e.g. Index***). Such variables are known as type handles. An instance of the type Index in any mode can be assigned to an Index*** handle. There is also a kind of supertype of all types and modes known as a Handle, to which instances of any type in any mode can be assigned. In contrast with Object in Java, this has no methods. Programs which work with Handle and/or with type handles can use a type-safe cast statement to determine the actual type and mode of an instance.

In accordance with (most of) the principles of persistence defined by Atkinson and Morrison [11] Timor programmers can assume that information is persistent unless and until it is explicitly deleted. That leads to vast simplifications in the writing of application programs, because they do not have to be concerned about using a separate "file system" or "database system" (see the section on Persistent Programming).