Multi dimensional array question.

BCS none at anon.com
Sun Jul 11 08:04:00 PDT 2010


Hello dcoder,

> Hello.
> 
> I'm wondering why in D if you declare a fixed multi dimensional array,
> you have to reverse the index order to access an element.  

When declaring an array, the base type is getting wrapped. When using an 
array, the base types get unwrapped.
Because both forms place the [] as a subfix and in both cases the sub-type/expression 
needs to be contiguous it end up the way it is.

alias int[5] T

T[7] aa;
T a = aa[6];
int v = a[4];

or

(int[5])[7] aa;
int v = (aa[6])[4];


-- 
... <IXOYE><





More information about the Digitalmars-d-learn mailing list