Routine Instantiation

next up previous contents index
Next: Procedure Invocation Up: Expressions Previous: Field Selection

Routine Instantiation

Instantiations of parameterized routines can be used as expressions. The form is

<idn> <actual_parms>
The idn must denote a routine definition (9.1,10.2). The actual parameters actual_parms are the parameters being supplied and legality checking is the same as for type instantiation (3.2.2). The value of such an expression is a routine object.

The type of the resulting routine is derived from the parameterized routine interface (9.3) by replacing each occurrence of a formal parameter with the corresponding actual. Thus for

p[T] (x: T) returns (T) signals (E)
      where T has lt(T ) returns (bool)
the instantiation
is legal and has type
proc (int) returns (int) signals (E)
Instantiation of parameterized methods is discussed in Section 7.10.