Scope & Structs
Salih Dincer
salihdb at hotmail.com
Sat Oct 12 14:12:27 UTC 2024
On Saturday, 12 October 2024 at 13:08:03 UTC, Nick Treleaven
wrote:
>
> If you want stack allocation of structs, why use `new`?
Actually, I almost never use the new operator except with(). I
was surprised because it seemed inconsistent here and wanted to
share my experiment.
On Saturday, 12 October 2024 at 13:11:52 UTC, Richard (Rikki)
Andrew Cattermole wrote:
> You are not wrong, when it is a struct, it is being heap
> allocated.
>
> Looks like the optimization for classes, hasn't been applied to
> structs.
>
> https://issues.dlang.org/show_bug.cgi?id=24806
So if `scope` is a facility for classes, it should give an error
when used in structures. Is that so? I understand this from the
issue you opened.
SDB at 79
More information about the Digitalmars-d-learn
mailing list