TAL Programmer's Guide
Comparing Procedures and Subprocedures
Using Procedures
11–14 096254 Tandem Computers Incorporated
Comparing
Procedures and
Subprocedures
Procedures and subprocedures are program units that can contain executable parts of
your program. A subprocedure is declared inside a procedure. A procedure can
contain any number of subprocedures, but a subprocedure cannot contain another
subprocedure. Neither procedures or subprocedures can contain another procedure.
You use procedures for operations needed throughout a program; procedures are
callable from anywhere in the program. You use subprocedures for operations needed
within a procedure; subprocedures are callable only from within the encompassing
procedure.
Procedures and subprocedures can declare formal parameters and receive data from
other procedures and subprocedures. The same procedure or subprocedure can
process different sets of data. The system allocates a private data area for each
activation of a procedure or subprocedure and deallocates that area when control
returns to the caller.
When a procedure or subprocedure calls a procedure (or when a subprocedure calls a
subprocedure), the system saves the environment of the caller and restores it when the
called procedure or subprocedure completes execution.
When a procedure calls a subprocedure, the caller’s environment remains in place
while the subprocedure executes.
Table 11-2 compares the characteristics of procedures and subprocedures.
Table 11-2. Procedures and Subprocedures
Characteristic Procedure Subprocedure
Can have formal parameters Yes, except MAIN procedure Yes
Can be a function and return a value Yes Yes
Can be recursive; it can call itself Yes Yes
Private primary storage 127 words local storage 32 words sublocal storage
Private secondary storage Yes No
Scope of procedure or subprocedure Global Local
Scope of data Local Sublocal
Can refer to which level of variables Global or local Global, local, or sublocal
Attributes MAIN
VARIABLE
EXTENSIBLE
RESIDENT
CALLABLE
PRIV
INTERRUPT
LANGUAGE (D-series
system)
VARIABLE
Other options FORWARD
EXTERNAL
FORWARD