On Wednesday, 17 August 2016 at 07:17:24 UTC, Rory McGuire wrote:

If DIP1000 is implemented, it will change that behavior, so the allocation will instead be on the GC heap, but the compiler will do some flow-control analysis to prevent escaping references. Is that right?

Mike


Not correct, the class would still be on the stack so we can have reference semantics during assignment etc, but the instance is on the stack so its faster and the function the code is inside can optionally be nogc.

DIP1000 will just make the compiler check that a stack instance does not escape its scope (though it doesn't cover all cases).

struct Astruct {} // - on stack by default
class Aclass  {} // - on heap by default
void main() {
Astruct a = new Astruct; // override, now Astruct is on the heap
(because of "new")
    Aclass c = new Aclass; // on the heap as per-usual
scope Aclass c1 = new Aclass; // override, now class is on the stack
(most obvious use: to make all references use the same instance)
}

Got it! Thank you! But it still appears that what's illustrated on the deprecations page is not being deprecated.

Mike

Reply via email to