Thread overview
[Issue 14026] More flexible array of array allocation syntax
Jan 22, 2015
Temtaime
Jan 22, 2015
Temtaime
Dec 17, 2022
Iain Buclaw
January 22, 2015
https://issues.dlang.org/show_bug.cgi?id=14026

Temtaime <temtaime@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |temtaime@gmail.com

--- Comment #1 from Temtaime <temtaime@gmail.com> ---
Why not int[][3] = new int[n][3]; ?
I think it's better.

--
January 22, 2015
https://issues.dlang.org/show_bug.cgi?id=14026

--- Comment #2 from bearophile_hugs@eml.cc ---
(In reply to Temtaime from comment #1)
> Why not int[][3] = new int[n][3]; ?
> I think it's better.

That syntax is already taken. n needs to be a compile-time constant, and it creates something different:

void main() @safe {
    enum int n = 2;
    auto m = new int[n][3];
    pragma(msg, typeof(m));
}

Output:

int[2][]

--
January 22, 2015
https://issues.dlang.org/show_bug.cgi?id=14026

--- Comment #3 from Temtaime <temtaime@gmail.com> ---
It's too strange in fact because for one dimension it works:

int n;
auto arr = new int[n];

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=14026

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
December 13
https://issues.dlang.org/show_bug.cgi?id=14026

--- Comment #4 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18933

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--