TAL Programmer's Guide
Operands
Using Expressions
096254 Tandem Computers Incorporated 5–11
LITERALs A LITERAL declaration specifies one or more identifiers and associates each with a
constant expression. Each identifier in a LITERAL declaration is known as a
LITERAL. You can define a LITERAL once and then reference it by identifier many
times in the program. When a you need to change a LITERAL, you only change the
declaration, not every reference to it.
LITERALs also make the source code more meaningful. For example, identifiers such
as BUFFER_LENGTH and TABLE_SIZE are more meaningful than their respective
constant values of 80 and 128.
When you declare LITERALs, you can specify a constant expression for each identifier
or you can let the compiler supply some or all of the constants.
Declaring LITERALs With Constants
To include constants in a LITERAL declaration, specify the keyword LITERAL and one
or more identifiers, each followed by an equal sign (=) and a constant expression.
Separate consecutive identifier and constant combinations with commas.
The constant expressions in a LITERAL declaration:
Can be numeric constants of any data type except STRING or UNSIGNED
Can be character strings that each contain at most four characters long
Must not be the address of a global variable
Here are examples of LITERAL declarations that include constant expressions:
LITERAL buffer_length = 80;
LITERAL true = -1,
false = 0,
chars = "AB";
Declaring LITERALs Without Constants
You can omit constants for one or more identifiers in a LITERAL declaration. The
compiler computes the omitted constants, using unsigned arithmetic:
If you omit the first constant in the declaration, the compiler supplies a zero.
If you omit a constant that follows an INT constant, the compiler supplies an INT
constant that is one greater than the preceding constant. If you omit a constant
that follows a constant of any data type except INT, an error message results.
This example shows how the compiler supplies constants in a LITERAL declaration:
LITERAL a, -- The compiler supplies 0
b, -- The compiler supplies 1
c, -- The compiler supplies 2
d = 0, -- You specify 0
e, -- The compiler supplies 1
f = 17, -- You specify 17
g, -- The compiler supplies 18
h; -- The compiler supplies 19