<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2013/12/20 Michel Fortin <span dir="ltr"><<a href="mailto:michel.fortin@michelf.ca" target="_blank">michel.fortin@michelf.ca</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
But what if your struct has a class-typed member:<br>
<br>
        struct A {<br>
                Object o;<br>
                int* a;<br>
<br>
                this(this) {<br>
                        a = new int;<br>
                        o = new Object;<br>
                }<br>
<br>
                this(this) immutable {<br>
                        a = new immutable(int);<br>
                        o = new immutable(Object); // will that work?<br>
                }<br>
        }<br>
<br>
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.<br>

<br>
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.</blockquote>
<div><br></div><div>That's already resolved "design issue" from 2.064, by fixing issue 9665.</div><div><a href="http://d.puremagic.com/issues/show_bug.cgi?id=9665">http://d.puremagic.com/issues/show_bug.cgi?id=9665</a><br>
</div><div><br></div><div>Inside constructor, first occured field assignment is automatically handled as the field initializing.</div><div><br></div><div>struct A {</div><div>    Object o;</div><div>    int* a;</div><div>
    this(int) immutable {</div><div>        a = new immutable(int);</div><div>        // is exactly same as: immutable int* a = new immutable(int);</div><div><br></div><div>        o = new immutable(Object);</div><div>        // is exactly same as: immutable(Object) o = new immutable(Object);</div>
<div>    }</div><div><br></div><div>Inside postblit, the same rule should be applied.</div><div><br></div><div>    this(this) immutable {</div><div>        a = new immutable(int);</div><div>        // is exactly same as: immutable int* a = new immutable(int);</div>
<div><br></div><div>        o = new immutable(Object);</div><div>        // is exactly same as: immutable(Object) o = new immutable(Object);</div><div>    }</div><div><br></div><div>Unfortunately postblit case does not work. I can say it's definitely a compiler bug.</div>
<div><a href="http://d.puremagic.com/issues/show_bug.cgi?id=11292">http://d.puremagic.com/issues/show_bug.cgi?id=11292</a></div><div><br></div><div>However, I'm purposely delaying to fix the bug, because of DIP49.</div>
<div><br></div><div>Kenji Hara </div></div></div></div>