TAL Programmer's Guide
Compilation Units
Structuring Programs
096254 Tandem Computers Incorporated 3–3
Figure 3-1 shows three procedures and a subprocedure. You can declare any number
of procedures in a compilation unit. You can declare any number of subprocedures
within any procedure. You cannot, however, declare a subprocedure within another
subprocedure.
The shading in Figure 3-1 represents the scope of identifiers—that is, the set of levels at
which you can access identifiers:
Identifiers in the unshaded areas have global scope. You can usually access global
identifiers from all compilation units in the program and from within the current
compilation unit.
Identifiers in the light gray areas have local scope. You can access local identifiers
only from within the encompassing procedure.
Identifiers in the dark gray area have sublocal scope. You can access sublocal
identifiers only from within the encompassing subprocedure.
Order of Components To structure a compilation unit, place declarations and statements in the following
order:
1. The NAME declaration, if present
2. Any unblocked global data declarations
3. Any blocked global data declarations
4. Procedure declarations. Within each procedure:
a. Any local data declarations
b. Any subprocedure declarations. Within each subprocedure:
1) Any sublocal data declarations
2) Any sublocal statements
c. Any local statements
The TAL compiler is a single-pass compiler. The prescribed ordering enables the
compiler to recognize the scope and other characteristics of your data. For example,
you must declare variables before you use their identifiers in statements.
The following subsections give more information on how to specify program
components.