pTAL Reference Manual (H06.08+)

Procedures, Subprocedures, and Procedure
Pointers
HP pTAL Reference Manual523746-006
14-33
Assignments to PROCPTRs
Assignments to PROCPTRs
You can assign values to a PROCPTR variable in much the same way as you assign
values to any variable; however, only values of data type PROCADDR can be
assigned to a PROCPTR.
You can assign the following items to a PROCPTR:
The address of a procedure or function
The value of another PROCPTR
The value of a variable whose data type is PROCADDR
Assignment statements involving PROCPTRs fall into one of two categories:
If the left side is a PROCPTR and right side is an @ character followed by the
name of a procedure, subprocedure, or functionthat is, neither the left side nor
the right side is a PROCADDR variablethe attributes and the formal parameter
types of each side of the assignment must match. The attributes specified must be
the same but do not have to be presented in the same order.
If either the left side or the right side of the assignment statement is a PROCADDR
variable, the compiler does not attempt to match attributes or parameter types.
Example 14-17. Assignments to PROCPTRs
PROCPTR pp1 (a, b) RETURNSCC;
INT a, b;
END PROCPTR;
PROCPTR pp2 (a) RETURNSCC;
INT a;
END PROCPTR;
PROCPTR pp3 (a, b);
INT a, b;
END PROCPTR;
PROC p(i, j) RETURNSCC;
INT i, j;
BEGIN
RETURN ,j;
END;
PROCADDR paddr;
paddr := @p; ! OK: PROCADDR variable is assigned PROC addr
@pp1 := @p; ! OK: Left side is PROCPTR, right side is PROC
@pp1 := @pp2; ! ERROR: pp1 has two parameters, pp2 has one
@pp1 := @pp3; ! ERROR: pp1 specifies RETURNSCC, pp3 does not
paddr := @pp2; ! OK: paddr is a PROCADDR variable
@pp1 := paddr; ! OK: paddr is a PROCADDR variable