pTAL Reference Manual (H06.03+)

LITERALs and DEFINEs
HP pTAL Reference Manual523746-005
6-6
How the Compiler Processes DEFINEs
DEFINE identifiers are not called when specified:
Within a comment
Within a character string constant
On the left side of a declaration
For example, the following declaration can call a DEFINE named y but not a
DEFINE named x:
INT x := y;
How the Compiler Processes DEFINEs
The compiler does not allocate storage for DEFINE declarations. When the compiler
encounters a statement using a DEFINE identifier, the compiler expands the DEFINE
declaration as follows:
It replaces the DEFINE identifier with the DEFINE body, replaces formal
parameters with actual parameters, and compiles the resulting declaration.
It expands quoted character strings intact.
It expands actual parameters after instantiation. Depending on the order of
evaluation, the expansion can change the scope
of a DEFINE declaration.
Emits machine instructions at the appropriate processing interval.
If the DEFEXPAND directive is active, the compiler lists each expanded DEFINE
declaration in the compiler listing following the invocation of the DEFINE. The
expanded listing includes:
The DEFINE body, excluding comments
Parameters to the DEFINE declaration
Example 6-4. Parenthesized and Nonparenthesized DEFINE Bodies
DEFINE expr = (5 + 2) #;
j := expr * 4; ! Expands to: (5 + 2) * 4;
! assigns 28 to j
DEFINE expr = 5 + 2 #;
j := expr * 4; ! Expands to: 5 + 2 * 4;
! assigns 13 to j