TAL Programmer's Guide
Using Parameters
Using Procedures
11–30 096254 Tandem Computers Incorporated
Arrays as Reference Parameters
If a procedure expects an array as an actual parameter, declare the formal parameter as
a simple pointer, preceding its identifier with an indirection symbol.
The following example declares two formal reference parameters (for array elements)
as simple pointers, one standard and the other extended:
PROC new_proc (array1, array2, elements_to_move);
INT .array1; !Declare simple pointers as formal
INT .EXT array2; ! parameters for array elements
INT elements_to_move;
BEGIN
!Manipulate the parameters
array1 ':=' array2 FOR elements_to_move ELEMENTS;
END;
Another procedure calls the preceding procedure and passes two arrays as actual
parameters. No indirection symbols precede the array identifiers in the CALL
statement:
PROC main_proc MAIN;
BEGIN
INT first[0:99]; !Declare arrays to pass
INT second[0:99];
CALL new_proc (first, second, 100);
!Call NEW_PROC; pass
END; ! arrays by reference
Passing the Array Size. When you pass an array, you also might need to pass the array
size or bounds information. (The declaration of the formal parameter does not
provide such information.)
The following example passes array size information:
LITERAL array_size = 10;
INT .EXT array[0:array_size - 1];
PROC p (a, s);
INT .EXT a;
INT s;
BEGIN
INT i;
INT n := s - 1;
FOR i := 0 TO n DO
a[i] := 0;
END;
PROC m MAIN;
BEGIN
CALL p (array, array_size); !Pass array size
END;