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

7- 8
END;
FUNCTION actual_funcparm1 (z : integer) : char; {user-defined function}
BEGIN
.
.
END;
PROCEDURE actual_procparm2; {another user-defined procedure}
BEGIN
.
.
END;
FUNCTION actual_funcparm2 : integer; {another user-defined function}
BEGIN
.
.
END;
BEGIN {prog}
p(actual_procparm1, {actual parameter for procparm1}
actual_funcparm1); {actual parameter for funcparm1}
s := f(actual_procparm2, {actual parameter for procparm2}
actual_funcparm2); {actual parameter for funcparm2}
END. {prog}
Parameters of Routine Types
Parameters of routine types
(procedure or function types) are like
parameters of other user-defined types. They are defined in the formal
parameter lists of other routines, but their types--routine types--are
defined in type declaration sections. The types must be declared first
(see the
HP Pascal/iX Reference Manual
or the
HP Pascal/HP-UX Reference
Manual
, depending on your implementation, for more information on
declaring routine types).
The actual parameter for a formal parameter of function type is either:
* The result of the function
addr
when applied to the name of a
user-defined function.
* The name of a variable of function type (in which case the value
of the variable must be a user-defined function).
In either case, the user-defined function and the formal parameter must
have congruent parameter lists and the same result type.
The actual parameter for a formal parameter of procedure type is either:
* The result of the function
addr
when applied to the name of a
user-defined procedure.
* The name of a variable of procedure type (in which case the value
of the variable must be a user-defined procedure).
In either case, the user-defined procedure and the formal parameter must
have congruent parameter lists.
Predefined routines cannot be actual parameters for formal parameters of
routine types. For information on variables of routine types, see
"Variables of Routine Types."
Example
The procedure p has a parameter of procedure type, procparm1, and a
parameter of function type, funcparm1. The function f has a parameter of
procedure type, procparm2, and a parameter of function type, funcparm2.
Compare this example to the example in "Routine Parameters" . See
"Congruent Parameter Lists" for examples of congruent parameter
lists. See "Fcall Function" and "Call Procedure" for information
on the
fcall
function and
call
procedure.