Review of DIP53
Timon Gehr
timon.gehr at gmx.ch
Sun Feb 2 17:18:56 PST 2014
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.
More information about the Digitalmars-d
mailing list