On Saturday, 12 October 2024 at 12:10:17 UTC, Salih Dincer wrote:
On Saturday, 12 October 2024 at 12:02:04 UTC, Salih Dincer wrote:
... even if I call the structure with the new operator. But if I stop using classes, scope doesn't work properly!

Declaring a `scope SomeClass` initialized with `new` is a special case to allocate on the stack:
https://dlang.org/spec/attribute.html#scope-class-var

Edit: It seems like scope is ineffective in structures. In fact, if there is the new operator, it is as if scope does not exist, and if it is construct without the new operator, it is as if scope does exist; is this normal?

If you want stack allocation of structs, why use `new`?


  • 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