auto arr = [1, 2, 3] should be a static array, not a GC allocated array

Nick Treleaven nick at geany.org
Mon Jul 25 08:09:31 UTC 2022


On Saturday, 23 July 2022 at 18:41:20 UTC, Dave P. wrote:
> Perhaps `scope` could be reused to mean the same thing?
>
> ```D
> scope arr = [1,2,3]; // guaranteed to be stack-allocated
> ```

Then arr is not a static array, it's a slice. See:
https://forum.dlang.org/post/jomlqltebzeambvwfrxp@forum.dlang.org


More information about the Digitalmars-d mailing list