On Friday, 14 March 2014 at 19:24:21 UTC, Chris Williams wrote:
In D, an array is a struct (struct Array), with an address and
a length value. A multi-dimensional array is an Array with an
address pointing to an array of Arrays. So with an int[2][2]
array, you have a layout like:
@1000 Array(address=1016, length=2)
@1016 [Array(address=1048, length=2),Array(address=1056,
length=2)]
@1048 [1,2]
@1056 [3,4]
This is not true; you need to distinguish between fixed-size and
dynamically sized arrays. It's better to call the latter "slices"
to avoid the confusion.
Fixed-size arrays are value types, there are no
references/addresses involved in storing them. So this:
int[2][2] a;
always has the following layout:
@1000 [1,2]
@1008 [3,4]
You layout would be correct for this example:
int[][] = [[1,2],[3,4]];