Loglan 82, A micro-manual of the programming language - Basic constructs and facilities

6) Adjustable arrays


In LOGLAN-82 arrays are adjustable at run time. They may be treated as objects of specified standard type with index instead of identifier selecting an attribute. An adjustable array should be declare somewhere among the lists of declarations and then may be generated in the sequence of statements.

Example:

A variable A is an array variable. Its value should be the reference to an integer array, i.e. a composite object consisting of integer components each one defined by an integer index.

Array generation statement:

allocates a one-dimensional integer array with the index bounds 1,n , and assigns its address to variable A.

The figure below illustrates this situation:

A general case of array generation statement has the form:

where lower and upper are arithmetic expressions which define the range of the array index.

Example:

Two-dimensional array declaration :

and generation:

create the structure:

Array A is the square array n by n. Each element A(i) , 1<=i<=n contains the address of row A(i,j), 1<=j<=n. Array B is the lower-triangular array. Each element B(i), 1<=i<=n, contains the address of row B(i,j), 1<=j<=i. Thus an assignment statement A(n,n):=B(n,n) transmits real value B(n,n) to real variable A(n,n). Assignment B(1):=A(1) transmits the address of the first row of A to variable B(1). Finally assignment B(1):=copy (A(1)) creates a copy of the first row of A and assigns its address to B(1).

Upper and lower bounds of an adjustable array A are determined by standard operators lower(A) and upper(A).

Example:

If an array variable A refers to no array its value is equal none (the standard default value of any array variable). An attempt to access an array element (e.g. A(i)) or a bound (e.g. lower(A)), where A is none, raises a run time error.




Last update 02/07/95
Comments, suggestions and critiques are welcome to : linfo062@crisv2.univ-pau.fr