HP Pascal/iX Reference Manual (31502-90022)

11- 14
A parallel can be drawn between pointers and PROCEDURE/FUNCTION
variables. While pointers are variables that reference data,
PROCEDURE/FUNCTION variables reference code.
Variables of PROCEDURE/FUNCTION types may be assigned procedures and
functions that have congruent parameter lists, as defined in HP Pascal.
See chapter 8 for more information on parameters. To assign a procedure
or function to a PROCEDURE/FUNCTION variable, the routine name is used as
a parameter to the addr function. See the section on predefined routines
in this chapter for more information on addr.
Any procedure or function assigned must have the same or wider scope than
the variable or value parameter to which it is assigned. Any
PROCEDURE/FUNCTION variable passed as a reference parameter must have the
same or wider scope than the formal parameter to which it is bound.
A PROCEDURE/FUNCTION variable can be assigned NIL.
The procedure or function referenced by a PROCEDURE/FUNCTION variable,
may be invoked by calling the predefined procedure call for a PROCEDURE
variable or the predefined function fcall for a FUNCTION variable. See
the section on predefined routines in this chapter for more information
on call and fcall.
Permissible Operators
assignment :=
relational =, <>
Standard Procedures
argument CALL
Standard Functions
argument FCALL
return ADDR
Example
TYPE
proc_0_type = PROCEDURE;
func_0_type = FUNCTION: integer;
proc_1_type = PROCEDURE( ANYVAR i : integer );
func_2_type = FUNCTION( VAR s : string;
i : integer ): boolean;
VAR
proc_0 : proc_0_type;
func_0 : func_0_type;
proc_1 : proc_1_type;
func_2 : func_2_type;
PROCEDURE p1; external;
PROCEDURE p2( n : shortint ); external;
PROCEDURE p3( VAR i : integer ); external;
BEGIN
func_0 := nil; { initialized to nil }