Up: Array References


4.5.1 Implicit size

For convenience, one may refer to the entire collection of an array with just the name of the instance. However, such an implicit collection reference is valid if and only if the implied collection (or sub-array) is densely packed.

some valid and invalid examples References with collapsing dimension:

     int y[3][4][5];
     int z[2][3];
     z[0..1][0..2] = y[2][2..3][0..2];  // y ref. collapses 1st dim.
     z[0..1][0..2] = y[1..2][1..3][3];  // y ref. collapses 3rd dim.
     z = y[0][2..3][0..2];
     int x[2][3];
     x = z;

(TODO: split the above example into several small ones...)

The idea of implicit collections extends to higher dimensions as well. Supposing the first m out of n dimensions are indexed, with k unspecified dimensions, then the number of dimensions of the reference is m-d+k or n-d, where d is the number of collapsed dimensions in m. In addition, for such a reference to be valid, the set of subarrays rooted at the nodes indexed by the first m dimensions must all be range-equivalent, not just size-equivalent. Implicit array references that do not satisfy this are considered errors.

[tons of examples]