----------------------
The (C) arrays are not the same thing as dynamic arrays of dynamic arrays
because:
- Some algorithms are not designed for a triangle where rows may differ in
length. Testing that rows are all the same length at runtime wastes time, and
if you don't test it then it may cause bugs;
- Sometimes you want to reshape a 2D matrix, so it's useful to store the matrix
in contiguous memory;
- Sometimes you need complex slicing, for example removal of some columns and
rows from a 2D matrix.
Recently in D.learn we have discussed this a bit.
In C# there are both arrays of arrays as in D, and rectangular dynamic arrays,
that are manages with a syntax similar to Pascal arrays: arr[x,y,z]. I think
there is no so need to put them into D. But I think it's important to have a
official type of them in Phobos, for example implemented as a struct (only the
item type and number of dimensions are known at compile time):
RectangularArray!(T, int ndimensions)
Well this might be a good time to mention that I've started to get back
to working on that std.matrix proposal for Phobos from a few months
back. Unfortunately, I wasn't able to work on it for a few months
(personal reasons). However, this may only solve the problem for numeric
types. On the other hand, with strategic use of __traits and static if....