DIP53 and DIP49 (ver2) - New definitions for qualified constructors and postblits

Michel Fortin michel.fortin at michelf.ca
Thu Dec 19 18:13:39 PST 2013


On 2013-12-20 02:07:32 +0000, Michel Fortin <michel.fortin at michelf.ca> said:

> But what if your struct has a class-typed member:
> 
> 	struct A {
> 		Object o;
> 		int* a;
> 
> 		this(this) {
> 			a = new int;
> 			o = new Object;
> 		}
> 
> 		this(this) immutable {
> 			a = new immutable(int);
> 			o = new immutable(Object); // will that work?
> 		}
> 	}
> 
> On the second postblit, the type of "a" has to be "immutable(int)*" to 
> allow you to assign something else to the pointer while not being able 
> to affect what's at the other end of the indirection.
> 
> So then, what is the type of "o"? Again, you need to be able to assign 
> the variable while not affecting what is at the other end of the 
> indirection. You need a tail-immutable object reference, which doesn't 
> exist.

I just want to add that this is not a criticism of the DIP in any way. 
I'm simply pointing out that it'll just make more visible an already 
embarrassing omission in the language.

-- 
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca



More information about the Digitalmars-d mailing list