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

7- 16
proc(f1);
proc(f2); {illegal}
r := func(f2);
r := func(f1); {illegal}
END.
The procedure proc has a function parameter, funcvar. The parameter list
of funcvar is congruent with the parameter list of the function f1, but
not with that of f2. Therefore, f1 can be an actual parameter for
funcvar, but f2 cannot.
The function func has a function parameter, fvar. The parameter list of
fvar is congruent with the parameter list of the function f2, but not
with that of f1. Therefore, f2 can be an actual parameter for fvar but
f1 cannot.
Example 3
This program uses a procedure parameter, procvar. The parameter list of
procvar includes conformant array parameters, w and x, another procedure
parameter, p1, and another function parameter, f1.
PROGRAM prog;
TYPE
itype = 1..10;
VAR
a : ARRAY [1..6] OF integer;
b : PACKED ARRAY [3..7] OF integer;
PROCEDURE alpha (m : integer); EXTERNAL;
FUNCTION beta (n : real) : integer; EXTERNAL;
PROCEDURE p (VAR cvar1 : ARRAY [a..b : itype] OF integer;
cvar2 : PACKED ARRAY [c..d : itype] OF integer;
PROCEDURE pvar (e : integer);
FUNCTION fvar (f : real) : integer;
); EXTERNAL;
PROCEDURE proc (PROCEDURE procvar
(VAR w : ARRAY [g..h : itype] OF integer;
x : PACKED ARRAY [i..j : itype] OF integer;
PROCEDURE p1 (x1 : integer);
FUNCTION f1 (x2 : real) : integer
)
);
BEGIN
procvar(a,b,alpha,beta);
END;
BEGIN
proc(p);
END.
The parameter lists of the formal procedure parameter procvar and the
procedure p are congruent: cvar1 and w are reference conformant array
parameters, cvar2 and x are value conformant array parameters, pvar and
function p1 are procedure parameters with congruent parameter lists, and
fvar and function f1 are function parameters with congruent parameter
lists.
Passing a routine as an actual parameter does not change its scope. If
it has access to a nonlocal entity before being passed as an actual
parameter, then it has access to that entity after being passed--even if
the entity is outside the scope of the routine to which the routine is