On Wednesday, 17 August 2016 at 04:28:33 UTC, Rory McGuire wrote:

Basically DIP1000 makes it so that:
void main()
{
    A obj;
    {
        scope A a = new A(1);
        obj = a;
    }
    assert(obj.x == 1);  // fails, 'a' has been destroyed
}

Will not compile.

Ok, that makes sense. But then the feature illustrated on the deprecations page is wrong. I think what has been deprecated is `scope` as a type modifier, not `scope` as a storage class, but the example on the deprecations page illustrates the `scope` storage class, not the type modifier.

I believe what the deprecations page intended to say was that this has been deprecated:
scope class A
{
    this(int x) { }
}

And DIP1000 finally implements the `scope` storage class properly:
void main()
{
    A obj;
    {
        scope A a = new A(1);
        obj = a;              // compile-time error.  Good!
    }
assert(obj.x == 1); // or is it usage that triggers the compile-time error?
}

Mike

Reply via email to