Does D provide anything like this? Otherwise, was this ever considered and were reasons found not to have it?

I mean at least in C# (not talking about C/C++ at all) you can declare two kind of multi-dimensional arrays: T[][][] or T[,,]. The first is the same as the D ones, array of arrays of... (except the order of the indices isn't inverted in C# type declarations IIRC); but the second provides contiguous, rectangular truly multi-dimensional arrays supposedly with one single level of indirection. (Of course static arrays don't exist in C# just dynamic but that's an apart issue.)

Is there a reason why this feature would not be really desirable or possible? Does it really exist and I missed it in Andrei's book? As a matter of fact he states in chapter 4.3:

«On the minus side, "tall and thin" arrays with many rows and few columns incur a large size overhead as there's one array to keep per column. [...] Jagged arrays may have problems with efciency of access and cache friendliness. Each element access requires two indirections [...] going column-wise through a jagged array is a cache miss bonanza.»

It would look that well implemented [,,] arrays would fill some application gaps, even though arrays of arrays (jagged in practice or not) are elsewhere useful as well of course. In the former cases I would think about defining my own struct wrapping a flat array with an n-dimensional api such as return _buff[i*m + j]... but generic in type and maybe also in dimension.

Again any special reason why this isn't already provided in the language? Either a generic struct/class like that, or something deeper in the language that allows using the [] operator as transparently as with any other arrays (as in C#).
Thanks for any input.

Reply via email to