On 12/18/2013 10:11 PM, Joseph Rushton Wakeling wrote:
And you have this(...) const (aka "unique"), which can be used to
construct both immutable and mutable instances.
It seems to me that this is a very natural relation to the existing
interpretation of mutable, immutable and const variables by the
language, and e.g. the way that immutable, mutable and const function
parameters are addressed.
The natural interpretation of a const constructor is that it constructs
a const object directly. Such a constructor could eg. initialize a field
declared with a mutable type using some external const reference.
void foo(const(int[]) a){
// ...
struct S{
int[] a;
this()const{
this.a=a;
}
}
// ...
}
The DIP argues that such a construct is not particularly useful and
hence eliminates it for the purpose of using the syntax for a
_different_ concept. There is no way to implement the above constructor
using the new semantics.