declaration/initialization of multidimensional arrays

Jonathan M Davis jmdavisProg at gmx.com
Sun Nov 18 18:17:54 PST 2012


On Sunday, November 18, 2012 21:06:58 Tyro[17] wrote:
> On 11/18/12 8:14 PM, bearophile wrote:
> >> Why is no one complaining about this array allocation syntax?
> > 
> > A syntax I like is:
> > 
> > new double[][3][](N, M)
> 
> Why not simply allow new double[N][3][M]; ?
> Seems a lot more intuitive/succinct than a separate []() implementation.

Because that declares a dynamic array of static arrays. You'd end up with a 
dynamic array of length N containing static arrays of length 3 containing 
static arrays of length M. The fact that you can declare dynamic arrays of 
static arrays screws with the syntax for declaring multidimensional arrays 
pretty thoroughly.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list