pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Example 213 Procedure Pointers in a Structure
STRUCT s1 [0:9];
BEGIN
REAL PROCPTR f(x); REAL x; END PROCPTR;
PROC32PTR g; END PROCPTR;
PROC64PTR h (x, y, z) EXTENSIBLE;
INT x, y, z;
END PROCPTR;
END;
Example 214 (page 268) declares a template structure s2 with three components. When s2 is the
referent of a referral structure, pTAL allocates space for procedure pointer f. pTAL does not allocate
space for procedure pointers g or h because they redefine procedure pointer f. Procedure pointers
f, g, and h are the same except for the type of the parameter passed to the procedure.
Example 214 Equivalenced Procedure Pointers in a Structure
STRUCT s2 (*);
BEGIN
REAL PROCPTR f(x);
REAL x;
END PROCPTR;
REAL PROC32PTR g(x);
INT x;
END PROCPTR = f;
REAL PROCPTR h(x);
FIXED x;
END PROCPTR = g;
END;
The code in Example 215 (page 268) uses the structure s2 in Example 214 (page 268).
Example 215 Code That Uses the Structure in Example 214 (page 268)
STRUCT s(s2);
REAL my_real;
INT my_index := type_int;
CASE my_index OF
BEGIN
type_real -> my_real := s.f(3.0E1);
type_int -> my_real := s.g(3);
type_fixed -> my_real := s.h(3F);
END;
Declaring PROCPTRs as Formal Parameters
The compiler:
• Ensures that the procedure attributes and parameter data types of procedures passed as actual
parameters match those defined in the formal parameters of the called procedure
• Builds parameter masks for calls to VARIABLE procedures and EXTENSIBLE procedures
268 Procedures, Subprocedures, and Procedure Pointers