Trying to understand multidimensional arrays in D
Profile Anaysis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jan 25 21:50:03 PST 2017
On Thursday, 26 January 2017 at 03:02:32 UTC, Jonathan M Davis
wrote:
> On Thursday, January 26, 2017 01:47:53 Profile Anaysis via
> Digitalmars-d- learn wrote:
>> [...]
>
> Like in C/C++, types are mostly read outward from the variable
> name in D. In both C/C++ and D,
>
> [...]
Actually, I think the notation is simply wrong.
// Matrix order testing
auto x = new int[][][][](1,2,3,4);
auto y = new int[1][2][][](3,4);
for(int i = 0; i < 1; i++)
for(int j = 0; j < 2; j++)
for(int k = 0; k < 3; k++)
for(int l = 0; l < 4; l++)
{
x[i][j][k][l] = i*j*k*l;
//x[l][k][j][i] = i*j*k*l;
//y[i][j][k][l] = i*j*k*l;
//y[l][k][j][i] = i*j*k*l;
y[k][l][j][i] = i*j*k*l;
}
It is inconsistent with dynamic arrays and mixing them creates a
mess in the order of indices.
I best someone was asleep at the wheel when programming the code
for static arrays. (probably someone different than who
programmed the dynamic arrays)
This is a bug IMO.(unfortunately one that can't be fixed ;/)
More information about the Digitalmars-d-learn
mailing list