Implementations

An implementation in Timor is introduced by the keyword impl followed by an implementation name. The latter consists of the name of the type being implemented followed by a double colon :: and the identifier of the implementation. For example an implementation of a type stack might have the name stack::arraystack.

 

Implementations can have the following sections.

A state section defines the state variables used in this implementation.

A retained section defines the variables which allow a thread to retain information between an open call and the corresponding close call.

A constr section defines the (only) constructor used for this implementation. (Different implementations can have different constructors.)

An instance section defines the implementations of the instance methods defined in the type definition.

A protected section defines implementations of the protected methods defined in the type definition.

A callback section defines implementations of the callback methods defined in the type definition.

An internal section allows the programmer to define methods which do not appear in the type definition. These cannot be directly invoked from outside the module.

 

A type can have multiple implementations. At the module interface level, these must be compatible with each other.

A type can be implemented in several ways:

1)         It can be complete self-contained, i.e. it is freshly coded independently of all other implementations. This remains true whether the type is a base type or is derived by inheritance from some other type.

2)         An implementation can re-use code from some other implementation which has some matching methods (regardless whether or not the underlying types stand in an inheritance relationship).

3)         It is also possible to create implementations which are typeless and to use these in implementations of types. Such free-standing typeless implementations have no significance for the type system. A typeless implementation is identified by a double colon (::) then an implementation identifier (without a preceding type name), e.g. ::usefulCode.