Language Reference/Interfaces

An interface definition defines a named object type. Interfaces can support other interfaces. See for further details.

All predicates declared in an interface are object members in objects of the interface type.

An interface is also a global scope, in which constants and domains can be defined. Thus constants and domains defined in an interface are not part of the type that the interface denotes (or of objects having this type).

Such domains and constants can be referenced from other scopes by qualification with the interface name: interfaceName::constant, or by using an open qualification. (See .)

 : interface    end interface -opt

 : 

See also Generic Interfaces and Classes and Monitors.

The  in the end of the construction must (if present) be identical to the one in the beginning of the construction.

The  must be of the kinds:



The  must be of the kinds:



All sections contained (transitively) in conditional sections must also be of those kinds.

The interface: object
If an interface does not explicitly support any interfaces, then it implicitly supports the build-in interface object.

The object is an empty interface, i.e. it contains no predicates etc.

The purpose of object is to be a universal base-type of all objects.

Open Qualification
Open qualifications are used to make references to class level entities more convenient. The open section brings the names of one scope into another scope, so that these can be referenced without qualification.

Open has no effect on the names of object members as these can only be accessed by means of an object anyway. But names of class members, domains, functors and constants can be accessed without qualification.

When names are brought into a scope in this way it may happen that some names becomes ambiguous (see ).

Open sections have only effect in the scope in which they occur. Especially this means that an open section in a class declaration has no effect on the class implementation.

 : open -comma-sep-list

Supports Qualification
Supports qualifications can only be used in and .

Supports qualifications are used for two things:


 * specifying that one interface A</vp> extends another interface B</vp> and, thereby, that the object type A</vp> is a subtype of the object type B</vp>
 * declaring that the objects of a certain class "privately" have more object types, than the one specified as construction type.

supports</vp> is a transitive relation: if an interface A</vp> supports</vp> an interface B</vp> and B</vp> in turn supports</vp> C</vp>, then A</vp> also supports</vp> C</vp>.

If an interface does not explicitly support any interfaces, then it implicitly supports the predefined interface object.

Functionally, it makes no difference whether an interface supports a certain interface more that once (directly and/or indirectly), but it might make a representational difference for the objects.

When supports</vp> is used in the implementation of a class, the result is that "This</vp>" not only can be used with the construction type, but also with any privately supported object type.

<SupportsQualification> : supports <InterfaceName>-comma-sep-list

<SupportsQualification> can only be used in and <ClassImplementation>.

Notice interfaces cannot be used together in a supports qualification, if they have conflicting predicates.

Predicates are conflicting if they have the same name and the arity but different origin interfaces.

The origin interface of a predicate is the interface in which the predicate is literally declared, as opposed to interfaces where it is indirectly declared by a supports qualification.

So it does not give conflicts, if the same interface is met twice or more in the supports chains.