To describe the argument and result types of operations, we use a notation like procedure signatures. But since most operations are too general to be described by a Modula-3 procedure signature, we extend the notation in several ways.
The argument to an operation can be required to have a type in a particular class, such as an ordinal type, set type, etc. In this case the formal specifies a type class instead of a type. For example:
ORD (x: Ordinal): IntegerThe formal type
Any
specifies an argument of any type.
A single operation name can be overloaded, which means that it denotes more than one operation. In this case, we write a separate signature for each of the operations. For example:
ABS (x: Integer) : Integer (x: Float) : FloatThe particular operation will be selected so that each actual argument type is a subtype of the corresponding formal type or a member of the corresponding formal type class. This selection is always unambiguous.
The argument to an operation can be an expression denoting a type. In this
case, we write Type
as the argument type. For example:
BYTESIZE (T: Type): CARDINALThe result type of an operation can depend on its argument values (although the result type can always be determined statically). In this case, the expression for the result type contains the appropriate arguments. For example:
FIRST (T: FixedArrayType): IndexType(T)
IndexType(T)
denotes the index type of the array type T
and
IndexType(a)
denotes the index type of the array a
. The
definitions of ElemType(T)
and ElemType(a)
are similar.
m3-support@elego.de