On 02/03/2014 01:58 AM, Andrei Alexandrescu wrote:

Overall, I'm not clear what DIP53 does.

It removes the concept of const constructors and inout constructors from the language. The old const constructor syntax is then used to introduce a new feature that is very similar to inout constructors (the unique constructor) but requires special type checking rules for const-qualified data. It mostly removes features. Eg, the following code will break:

auto foo(const(int)[] x){
    struct S{
        int[] x;
        this(int y)const{ this.x=x; }
    }
    // ...
}

Some new code that wouldn't have been possible to write in an analogous way before:

struct S{
    int x;
    int[] y;
    this(int delegate(inout(int)[]) dg, inout(int)[] x)const{
        this.x=dg(x);
        this.y=[this.x];
    }
}

void main(){
    immutable s = S(x=>x[0],[1]);
    auto s = S((immutable x)=>x[0],cast(immutable)[2]);
}

Whatever strange class of new use cases DIP53 actually enables is fully covered by multiple inout-qualifiers as discussed in my previous post.

Reply via email to