pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Example 216 Procedure Pointers as Formal Parameters
PROC a(i); INT i; EXTERNAL;
PROC b(p);
PROCPTR p(a); INT a; END PROCPTR;
EXTERNAL;
PROC c(p);
PROC64PTR p(a); INT a; END PROCPTR;
EXTERNAL;
PROC d(pa); PROCADDR pa; BEGIN END;
PROC e(pa); PROC32ADDR pa; BEGIN END;
PROC f;
BEGIN
CALL b(a); ! OK
CALL b(@a); ! ERROR: @ character is not valid
CALL c(a); ! OK
CALL c(@a); ! ERROR: @ character is not valid
CALL d(a); ! ERROR: @ character is required
CALL d(@a); ! OK
CALL e(a); ! ERROR: @ character is required
CALL e(@a); ! OK
END;
NOTE: Address type PROC32ADDR and procedure pointer type PROC64PTR are 64-bit addressing
functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information,
see Appendix E, “64-bit Addressing Functionality” (page 531).
An @ character in front of the actual parameter is:
• Not allowed if the formal parameter is a PROC or a PROCPTR
• Required if the formal parameter is a PROCADDR
Assignments to Procedure Pointers
You can assign values to a procedure pointer variable in much the same way as you assign values
to any variable; however, only values of data type procedure address can be assigned to a
procedure pointer.
You can assign the following items to a procedure pointer:
• The address of a procedure or function
• The value of another procedure pointer
• The value of a variable whose data type is procedure address
Assignment statements involving procedure pointers fall into one of two categories:
• If the left side is a procedure pointer and right side is an @ character followed by the name
of a procedure, subprocedure, or function—that is, neither the left side nor the right side is a
procedure address variable—the 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 procedure address
variable, the compiler does not attempt to match attributes or parameter types.
• Subject to the matching rules above, you can assign procedure pointers and procedure
addresses to other procedure pointers and procedure addresses if the size of the target is
equal to or larger than the size of the source.
Procedure Pointers 269