Inferring static array size
Mike Parker
aldacron at gmail.com
Sun Apr 28 09:46:24 UTC 2024
On Sunday, 28 April 2024 at 09:31:01 UTC, NotYouAgain wrote:
> The idea is simple, really, really simple.
>
> Instead of this:
>
> int[5] a = [1, 2, 3, 4, 5];
>
> allow this:
>
> int[$_] a = [1, 2, 3, 4, 5];
>
> Both are static arrays.
>
> Having to change the length everytime i change the
> initialisation list is a pain in the $____
>
> The compiler infers the size in the second example, based on
> the number of elements in the initialisation list. Just like C
> can do.
FYI, a DIP for this was submitted and withdrawn by the author in
response to negative feedback. See below, and particularly the
"Reviews" section at the bottom of the document.
https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1039.md
More information about the dip.ideas
mailing list