HP Pascal/iX Programmer's Guide (31502-90023)

7- 10
Variables of Routine Types
Variables of routine types (procedure and function types) can be actual
parameters for formal parameters of routine types (function and procedure
types, respectively). See "Parameters of Routine Types" .
The values that you can assign to a function variable are:
* The value
nil
.
* The value returned by the predefined function
addr
when you call
it with the name of an appropriate function (
appropriate
is
defined below).
* The value returned by any function whose return type is the same
function type as that of the variable.
* Another function variable of the same type.
The values that you can assign to a procedure variable are:
* The value
nil
.
* The value returned by the predefined function
addr
when you call
it with the name of an appropriate procedure (
appropriate
is
defined below).
* The value returned by any function whose return type is the same
procedure type as that of the variable.
* Another procedure variable.
A routine is an
appropriate
parameter for
addr
under these conditions:
* The routine and the variable have congruent parameter lists.
* In the case of a function and a function variable, if they have
the same result type.
* The routine is declared at the same or a higher level than the
variable.
* The routine is not predefined.
Routine variables are system programming extensions. To use them,
specify $STANDARD_LEVEL 'HP_MODCAL'$. Refer to the
HP Pascal/iX
Reference Manual
or the
HP Pascal/HP-UX Reference Manual
, depending on
your implementation, for more information on compiler options.
Example 1
This program uses the predefined function
addr
to assign appropriate
functions to a variable of function type and appropriate procedures to a
variable of procedure type.
$STANDARD_LEVEL 'HP_MODCAL'$
PROGRAM proc (input);
TYPE
proctype = PROCEDURE (x,y : integer);
functype = FUNCTION (x,y : integer) : integer;
VAR
procvar : proctype;
funcvar : functype;
b : Boolean;
i : integer;