<p dir="ltr"></p>
<p dir="ltr">On 17 Aug 2016 04:00, "Mike via Digitalmars-d-announce" <<a href="mailto:digitalmars-d-announce@puremagic.com">digitalmars-d-announce@puremagic.com</a>> wrote:<br>
><br>
> On Wednesday, 17 August 2016 at 01:42:00 UTC, Walter Bright wrote:<br>
><br>
>>> Can you please clarify the current implementation `scope`, and what DIP1000<br>
>>> proposes to change with respect to the current implementation?<br>
>><br>
>><br>
>> It just adds to the existing compiler implementation of 'scope'. It has nothing to do with std.typecons.scoped.<br>
><br>
><br>
> Ok, but the deprecations page [1] gives this example...<br>
><br>
> class A<br>
> {<br>
>     int x;<br>
>     this(int x) { this.x = x; }<br>
> }<br>
><br>
> void main()<br>
> {<br>
>     A obj;<br>
>     {<br>
>         scope A a = new A(1);<br>
>         obj = a;<br>
>     }<br>
>     assert(obj.x == 1);  // fails, 'a' has been destroyed<br>
> }<br>
><br>
> ... as a deprecated pattern, and corrected with ...<br>
><br>
> class A<br>
> {<br>
>     this(int x) { }<br>
> }<br>
> void main()<br>
> {<br>
>     auto a = std.typecons.scoped!A(1);<br>
> }<br>
><br>
> However, in DIP1000, the examples use the above deprecated pattern extensively.  So what's the story?  Does the deprecations page [1] need an update?<br>
><br>
> [1] <a href="http://dlang.org/deprecate.html#scope%20for%20allocating%20classes%20on%20the%20stack">http://dlang.org/deprecate.html#scope%20for%20allocating%20classes%20on%20the%20stack</a></p>
<p dir="ltr">Basically DIP1000 makes it so that:<br>
> void main()<br>
> {<br>
>     A obj;<br>
>     {<br>
>         scope A a = new A(1);<br>
>         obj = a;<br>
>     }<br>
>     assert(obj.x == 1);  // fails, 'a' has been destroyed<br>
> }</p>
<p dir="ltr">Will not compile.<br></p>