Unchecked arrays

The UncheckedArray[T] type is a special kind of array where its bounds are not checked. This is often useful to implement customized flexibly sized arrays. Additionally an unchecked array is translated into a C array of undetermined size:

  1. type
  2. MySeq = object
  3. len, cap: int
  4. data: UncheckedArray[int]

Produces roughly this C code:

  1. typedef struct {
  2. NI len;
  3. NI cap;
  4. NI data[];
  5. } MySeq;

The base type of the unchecked array may not contain any GC’ed memory but this is currently not checked.

Future directions: GC’ed memory should be allowed in unchecked arrays and there should be an explicit annotation of how the GC is to determine the runtime size of the array.