auto arr = [1, 2, 3] should be a static array, not a GC allocated array
Dave P.
dave287091 at gmail.com
Sat Jul 23 18:41:20 UTC 2022
On Thursday, 14 July 2022 at 13:14:59 UTC, ryuukk_ wrote:
> It is misleading, nobody expect this to be GC allocated
>
> It should be equal to:
>
> ```D
> int[3] arr = [1, 2, 3]
> ```
>
> Also why it is GC allocated without requiring ``new``?
Perhaps `scope` could be reused to mean the same thing?
```D
scope arr = [1,2,3]; // guaranteed to be stack-allocated
```
More information about the Digitalmars-d
mailing list