TAL Programmer's Guide
Using Parameters
Using Procedures
096254 Tandem Computers Incorporated 11–23
PROC Value Parameters. Specify a procedure as a formal PROC parameter if the actual
parameter is the address of:
A C small-memory-model routine
A FORTRAN routine compiled with the NOEXTENDEDREF directive
A TAL procedure or function procedure
For each actual PROC parameter, the compiler allocates a word of storage in the
parameter area of the called procedure. The actual PROC parameter is a 16-bit address
that contains the PEP and map information of the passed procedure.
The following example contains the following procedures:
GREATER_THAN, which is passed as an actual PROC parameter
BUBBLE_SORT, which declares the formal PROC parameter
SORT, which calls BUBBLE_SORT and passes GREATER_THAN to it
LITERAL s = 10;
INT .a[0:s - 1] := [10,9,8,7,6,5,4,3,2,1];
INT PROC greater_than (a, b); !Declare actual PROC parameter
INT a, b;
BEGIN
IF a > b THEN RETURN -1
ELSE RETURN 0;
END;
PROC bubble_sort (array, size, compare_function);
INT .array;
INT size;
INT PROC compare_function; !Declare formal PROC parameter
BEGIN
INT i, j, temp, limit;
limit := size - 1;
FOR i := 0 TO limit -1 DO
FOR j := i + 1 TO limit DO
IF compare_function (array[i], array[j]) THEN
BEGIN
temp := array[i];
array[i] := array[j];
array[j] := temp;
END;
END;
PROC sort MAIN;
BEGIN
CALL bubble_sort (a, s, greater_than);
END;