Differing semantics between multidimensional fixed-length array and slice initialization

bearophile bearophileHUGS at lycos.com
Sun Mar 31 18:49:13 PDT 2013


Nicholas Smith:

> Can anyone explain reasoning behind this?

To help confuse you a little more, this syntax is also allowed in 
D:

int array[2][3];

Plus of course a mixed D/C 
(http://d.puremagic.com/issues/show_bug.cgi?id=5807 ):

int[2] array[3];

Mixing fixed size arrays with dynamic ones is interesting:

auto array1 = new int[3][](2);
auto array2 = new int[][3][](2);

D array definition syntax is one of the cases where I think the 
Ada/ObjectPascal syntax is better.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list