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

Reply via email to