Why is `scope` planned for deprecation?

Manu via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 10 19:56:43 PST 2014


I think the general direction is that scope will be re-purposed as a
type modifier for implementing effective borrowing/escape analysis.
...at least, I really really hope that's the plan! :)

On 11 November 2014 09:33, Mike via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> First of all, what exactly is planned for deprecated? It [1] says "Note that
> scope for other usages (e.g. scoped variables) is unrelated to this feature
> and will not be deprecated.", but the example...
>
> void main()
> {
>     A obj;
>     {
>         scope A a = new A(1);
>         obj = a;
>     }
>     assert(obj.x == 1);  // fails, 'a' has been destroyed
> }
>
> ... looks a lot like a scoped variable to me, so it's not clear to me what
> exactly is planned for deprecation. Please clarify.
>
>
> Ok, with that out of the way, I get why it is unsafe, but isn't it only
> unsafe because it has not yet been implemented?  Isn't it possible to
> implement escape analysis and make it a safe and useful feature?
>
> This question was asked before, but never received an answer.[2]
>
> Mike
>
> [1]
> http://dlang.org/deprecate.html#scope%20for%20allocating%20classes%20on%20the%20stack
> [2] http://forum.dlang.org/post/k549l4$1s24$1@digitalmars.com


More information about the Digitalmars-d mailing list