<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 17, 2016 at 9:04 AM, Mike via Digitalmars-d-announce <span dir="ltr"><<a href="mailto:digitalmars-d-announce@puremagic.com" target="_blank">digitalmars-d-announce@puremagic.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
<br></div></div>
Or perhaps DIP1000 changes the current behavior of the `scope` storage class.<br>
<br>
My understanding is that the `scope` storage class currently allocates a class on the stack (though its usage for this purpose is deprecated in favor of std.typecons.scoped).</blockquote><div><br></div><div>Correct. I believe the reason for the deprecation was that it was too easy to use considering how easy it was to get it's usage wrong, and that a library implementation would be just as good, which would also lessen the number of reserved words D has, and make devs more likely to check the documentation for its caveats.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">  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?<br>
<br>
Mike<br></blockquote><div><br></div><div>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.</div><div><br></div><div>DIP1000 will just make the compiler check that a stack instance does not escape its scope (though it doesn't cover all cases).</div><div><br></div><div>struct Astruct {} // - on stack by default</div><div>class Aclass  {} // - on heap by default</div><div>void main() {</div><div>    Astruct a = new Astruct; // override, now Astruct is on the heap (because of "new")</div><div>    Aclass c = new Aclass; // on the heap as per-usual<br>    scope Aclass c1 = new Aclass; // override, now class is on the stack (most obvious use: to make all references use the same instance)</div><div>}</div><div><br></div><div> </div></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div></div>