Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1

jmh530 john.michael.hall at gmail.com
Mon Jan 11 21:17:20 UTC 2021


On Monday, 11 January 2021 at 14:42:57 UTC, Nick Treleaven wrote:
> [snip]
>
> Just a suffix like `[1,2]$` or `[1]s`. Then just use `auto var 
> =` with it as normal.

Gotcha. I think I would use that more than the current DIP 
(though I prefer [1]s to [1]$).

Of course, the typical response would be, "well why not use alias 
s = static array". I would ask what about an @nogc unittest where 
the author is trying to limit calls to functions that aren't 
really central to what is being tested. The next best alternative 
is something like `enum immutable x = [1];` and then using `x`. 
Building that static array literal functionality into the 
compiler would be useful in that case.


More information about the Digitalmars-d-announce mailing list