Inferring static array size
ryuukk_
ryuukk.dev at gmail.com
Sun Apr 28 10:17:06 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.
YES please, this is long overdue, there is no reason to not have
this
However, i don't like the proposed syntax, it should be 1
character to type, and should not be a ugly one
`_` should be enough
More information about the dip.ideas
mailing list