pTAL Guidelines for TAL Programmers

Differences Between TAL and pTAL
pTAL Guidelines for TAL Programmers527256-002
3-16
Declaring PROC Formal Parameters
Declaring PROC Formal Parameters
In TAL, you can declare parameters of type PROC. If you pass a variable or extensible
procedure to a formal parameter whose data type is PROC, you must explicitly include
code in the called procedure to push a parameter mask and parameter count onto the
stack before you call the procedure passed in the PROC parameter, as in Example 3-9
on page 3-16.
STRUCT sstr;
BEGIN
PROCADDR c;
PROCPTR d;
END PROCPTR = a; !ERROR: a & d are at different levels
PROCPTR e;
END PROCPTR = c; ! OK: c & e are at same level
PROCPTR f;
END PROCPTR = d; ! OK: d & f are at same level
PROCPTR g;
END PROCPTR = b; ! ERR: b & g are at different levels
END;
PROCPTR h;
END PROCPTR = a; ! OK: a & h are at same level
PROCPTR i;
END PROCPTR = b; !OK: b & i are at same level
END;
Example 3-9. Passing an EXTENSIBLE Procedure to a PROC Formal Parameter
(TAL Only)
PROC p1 (i, j) EXTENSIBLE;
INT i, j;
EXTERNAL;
PROC p2( p );
PROC p;
BEGIN
! Build extensible parameter mask
! Push extensible parameter mask on stack
! Push count word on stack
CALL p(1, 2); ! Call p, which really calls p1
END;
PROC p3;
BEGIN
CALL p2(p1); ! Call p2, passing p1
END;
Example 3-8. Valid and Invalid Structure Redefinitions (page 2 of 2)