Array literals' default type

Jarrett Billingsley jarrett.billingsley at gmail.com
Sat Oct 10 07:12:56 PDT 2009


On Sat, Oct 10, 2009 at 7:33 AM, Yigal Chripun <yigal100 at gmail.com> wrote:
>
> You keep calling these literals "constructor calls' and I agree that that's
> what they are. My question is then why not make them real constructors?
>
> auto a = new int[](x, y, z);

Teehee, that syntax already has meaning in D. Well, that right there
would give you a semantic error, but "new int[][][](x, y, z)" creates
a 3-D array with dimensions x, y, and z.

That brings up another point. If you *did* use a class-style ctor
syntax, how would you list the arguments for a multidimensional array?
That is, what would be the equivalent of [[1, 2], [3, 4]]?



More information about the Digitalmars-d mailing list