TAL Reference Manual
LITERALs and DEFINEs
TAL Reference Manual—526371-001
5-8
Examples of Passing DEFINE Parameters
If the number of actual parameters exceeds the number of formal parameters, the
compiler issues an error. For example:
DEFINE something (a, b, c) = anything and everything #;
nothing := something (a, b, c, d); !Too many parameters
You can pass a DEFINE that has no formal parameters as an actual parameter. For
example:
defmacro (DEFINE x = y + y #); !Invocation
If an actual parameter in a DEFINE invocation requires commas, enclose each comma
in apostrophes ('). An example is an actual parameter that is a parameter list:
DEFINE varproc (proc1, param) = CALL proc1 (param) #;
varproc (myproc, i ',' j ',' k); !Expands to:
! CALL MYPROC (I, J, K);"
An actual parameter in a DEFINE invocation can include parentheses. For example:
DEFINE varproc (proc1, param) = CALL proc1 (param) #;
varproc (myproc, (i + j) * k); !Expands to:
! CALL MYPROC ((I+J)*K);
Examples of Passing DEFINE Parameters
Here are more examples of passing actual parameters.
1. This example shows a DEFINE declaration that has one formal parameter and an
assignment statement that uses the DEFINE identifier, passing a parameter of 3:
DEFINE cube (x) = ( x * x * x ) #;
INT result;
result := cube (3) '>>' 1;
!Expands to: (3 * 3 * 3) '>>' 1 = 27 '>>' 1 = 13
2. This example provides incrementing and decrementing utilities and a statement
that uses one of the utilities:
DEFINE increment (x) = x := x + 1 #;
DEFINE decrement (y) = y := y - 1 #;
INT index := 0;
increment(index); !Expands to: INDEX := INDEX + 1;