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@79
  • Scope & Stru... Salih Dincer via Digitalmars-d-learn
    • Re: Scope &... Salih Dincer via Digitalmars-d-learn
      • Re: Sco... Nick Treleaven via Digitalmars-d-learn
        • Re:... Salih Dincer via Digitalmars-d-learn
          • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
    • Re: Scope &... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: Sco... Salih Dincer via Digitalmars-d-learn
        • Re:... Nick Treleaven via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... Salih Dincer via Digitalmars-d-learn

Reply via email to