TAL Programmer's Guide

Declaring and Calling Subprocedures
Using Procedures
11–16 096254 Tandem Computers Incorporated
Sublocal Variables Because each subprocedure has only a 32-word storage area for variables, declare large
arrays or structures at the global or local level and make them indirect. In
subprocedures, declare only pointers and directly addressed variables as follows:
Valid Sublocal Variables Example
Simple variables INT var;
Arrays INT array[0:5];
Read-only arrays INT ro_array = 'P' := [0,1,2,3,4,5];
Structures STRUCT struct_a;
BEGIN
INT a, b, c;
END;
Simple pointers INT .simple_ptr;
Structure pointers STRING .struct_ptr (struct_a);
If you specify an indirection symbol (. or .EXT) when you declare sublocal arrays and
structures, the compiler allocates direct arrays and structures and issues a warning.
Invalid Sublocal Variables Example
Indirect arrays INT .EXT ext_array[0:5];
Indirect structures STRUCT .EXT ext_struct;
BEGIN
INT a, b, c;
END;
Visibility of Identifiers Sublocal statements can normally refer to sublocal identifiers in the subprocedure,
local identifiers in the procedure, and global identifiers. If, however, you declare the
same identifiers (such as A and B ) at the sublocal, local, and global levels, the
subprocedure can access only the sublocal identifiers (A and B):
INT a := 9; !Declare global A and B
INT b := 3;
PROC a_proc MAIN; !Declare A_PROC
BEGIN
INT a := 4; !Declare local A and B
INT b := 1;
INT c;
SUBPROC a_subproc (param); !Declare A_SUBPROC
INT param;
BEGIN
INT a := 5; !Declare sublocal A and B
INT b := 2;
c := a + b + param; !Access sublocal A and B
END; !End A_SUBPROC
a := a + b; !Access local A and B
CALL a_subproc (a);
END; !End A_PROC