pTAL Guidelines for TAL Programmers
Coding Guidelines
pTAL Guidelines for TAL Programmers—527256-002
2-30
$OPTIONAL Routine
$OPTIONAL Routine
Guideline: Use the $OPTIONAL built-in routine to control whether parameters are
passed to variable and extensible procedures.
The built-in routine $OPTIONAL, available in both TAL and pTAL, enables your
program to determine at run time whether to pass a particular parameter to a variable
or extensible procedure.
In Example 2-28 on page 2-30, procedure p is a front end to procedure q and passes a
parameter to q only if a parameter was passed to p.
Example 2-29 on page 2-30 is the same as Example 2-28 on page 2-30 except that the
parameter to q is a parameter pair.
Example 2-28. $OPTIONAL Routine
PROC q(i) EXTENSIBLE;
INT i;
BEGIN
...
END;
PROC p(k) EXTENSIBLE;
INT k;
BEGIN
CALL q($OPTIONAL($PARAM(k), k));
END;
Example 2-29. $OPTIONAL Routine With Parameter Pair
PROC q(t:i) EXTENSIBLE;
STRING .t;
INT i;
BEGIN
...
END;
PROC p(s:k) EXTENSIBLE;
STRING .s;
INT k;
BEGIN
CALL q($OPTIONAL($PARAM(s), s:k));
END;