On 2013-12-20 02:07:32 +0000, Michel Fortin <[email protected]> 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
[email protected]
http://michelf.ca

Reply via email to