TAL Reference Manual
LITERALs and DEFINEs
TAL Reference Manual—526371-001
5-7
Compiler Action
For example, the following declaration can invoke a DEFINE named Y but not a
DEFINE named X:
INT x := y;
Compiler Action
The compiler allocates no storage for DEFINEs. When the compiler encounters a
statement that uses a DEFINE identifier, the compiler expands the DEFINE as follows:
•
It replaces the DEFINE identifier with the DEFINE body, replaces formal
parameters with actual parameters, compiles the DEFINE, and emits any machine
instructions needed.
•
It expands quoted character strings intact.
•
It expands actual parameters after instantiation. Depending on the order of
evaluation, the expansion can change the lexical scope of a DEFINE declaration.
If the DEFEXPAND directive is in effect, the compiler lists each expanded DEFINE in
the compiler listing following the DEFINE identifier. The expanded listing includes:
•
The DEFINE body, excluding comments
•
The lexical level of the DEFINE, starting at 1
•
Parameters to the DEFINE
Parameters are listed as
$n (C-series system) or #n (D-series system), where n is the
sequence number of the parameter, starting at 1.
Passing Actual Parameters
If the DEFINE declaration has formal parameters, you supply the actual parameters
when you use the DEFINE identifier in a statement.
The number of actual parameters can be less than the number of formal parameters. If
actual parameters are missing, the corresponding formal parameters expand to empty
strings. For each missing actual parameter, you can use a placeholder comma. For
example:
INT PROC d (a, b, c) EXTENSIBLE; EXTERNAL;
DEFINE something (a, b, c) = d (a, b, c) #;
nothing := something ( , , c); !Placeholder commas
If a DEFINE has formal parameters and you pass no actual parameters to the DEFINE,
you must specify an empty actual parameter list. You can include commas between the
list delimiters, but need not. For example:
DEFINE something (a, b, c) = anything and everything #;
nothing := something ( ); !Empty parameter list