auto arr = [1, 2, 3] should be a static array, not a GC allocated array
Daniel N
no at public.email
Sun Jul 17 17:23:18 UTC 2022
On Sunday, 17 July 2022 at 16:33:29 UTC, Nick Treleaven wrote:
>
> ```d
> auto sa = $[1,2,3,4];
> ```
>
> That avoids supporting partial `auto` declarations (a reason
> why Walter didn't like that PR). It also allows inference when
> passing a literal to a template function argument where the
> parameter is not already a static array. The `$[]` syntax would
> literally mean "length array", i.e. fixed length array. (Why do
> we overload the word 'static' here for arrays?)
>
Hmm, it's not half bad!
Another idea... to enumerate all possibilities.
```d
scope sa = [1,2,3,4];
```
More information about the Digitalmars-d
mailing list