[Oberon] compiler restriction

Pieter Muller pieter.muller at alumni.ethz.ch
Thu May 1 12:53:32 CEST 2003


Soren Renner wrote:

>No more than 2**14 - 1 pointers may appear in a record or the compiler 
>(the one that comes with the latest Bluebottle) chokes. How difficult 
>would it be to change this restriction, so that
>
>TYPE  ar=ARRAY 500 500 500 OF OBJECT
>
>would be acceptable? Yes, I really have a reason to do this . . .
>
You could use nested arrays of pointers instead, which will use less 
space if they are sparse.  Example (non-sparse):

CONST
  P = 500; Q = 500; R = 500;

TYPE
  Array1 = POINTER TO ARRAY OF OBJECT;
  Array2 = POINTER TO ARRAY OF Array1;
  Array = POINTER TO ARRAY OF Array2;

VAR
  a: Array;
  i, j, k: INTEGER;

BEGIN
  NEW(a, P);
  FOR i := 0 TO P-1 DO
    NEW(a[i], Q);
    FOR j := 0 TO Q-1 DO
      NEW(a[i][j], R);
      FOR k := 0 TO R-1 DO a[i][j][k] := obj END
    END
  END
END

-- Pieter





More information about the Oberon mailing list