<div dir="ltr">2013/11/10 Timon Gehr <span dir="ltr"><<a href="mailto:timon.gehr@gmx.ch" target="_blank">timon.gehr@gmx.ch</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">On 11/10/2013 07:46 AM, Kenji Hara wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<a href="http://wiki.dlang.org/DIP49" target="_blank">http://wiki.dlang.org/DIP49</a><br>
<br>
Experimental compiler/druntime patches (WIP, 80% completed):<br>
<a href="https://github.com/9rnsr/dmd/tree/qual_pblit" target="_blank">https://github.com/9rnsr/dmd/<u></u>tree/qual_pblit</a><br>
<a href="https://github.com/9rnsr/druntime/tree/qual_pblit" target="_blank">https://github.com/9rnsr/<u></u>druntime/tree/qual_pblit</a><br>
<br>
Kenji Hara<br>
</blockquote>
<br></div>
Well written DIP!<br></blockquote><div><br></div><div>Thank you!</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
- Rules [c1] and [c5] are unsound and should be removed.<br>
<br>
const(int)[] constglobal;<br>
<br>
struct S{<br>
int[] arr;<br>
this(this)const{<br>
arr = constglobal;<br>
}<br>
}<br>
<br>
int[] coerceC1Unsound(const(int)[] g){<br>
constglobal = g;<br>
S s;<br>
S t=s;<br>
// ... (any code that makes the above invoke postblit)<br>
return t.arr;<br>
}<br>
<br>
immutable(int)[] coerceC5Unsound(const(int)[] g){<br>
constglobal = g;<br>
S s;<br>
immutable(S) t=s;<br>
// ... (ditto)<br>
return t.arr;<br>
}<br></blockquote><div><br></div><div>Oops... Indeed [c1] and c5] may break type system... I deleted these rules from the DIP.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
- Typo in immutable postblit description: "You can regard the [i2] case<br>
as that the generated immutable copy is referred by const reference."<br>
Should read: "You can regard the [i1] case ..."<br></blockquote><div><br></div><div>Thanks. Fixed. </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
- Unique postblit:<br>
= The general concept seems useful, but what about this case:<br>
<br>
struct S{<br>
int[] a; // should be shared between all copies<br>
int[] b; // should be cloned across copies<br>
<br>
this(this)/+same qualifier on source and target+/{<br>
b = b.dup;<br>
}<br>
}<br>
<br>
void main(){<br>
S s;<br>
immutable(S) t;<br>
auto g = s;<br>
auto h = t;<br>
// ...<br>
}<br>
<br>
= Do you think that in this case one should implement identical<br>
mutable and immutable postblit?<br></blockquote><div><br></div><div>I think yes.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
= "Pure function call which returns unique object"<br>
-> "Strongly pure ..."<br></blockquote><div><br></div><div>This is valid. Because not only strongly pure function will return unique object.</div><div><br></div><div>For example:</div><div> immutable(int)[] foo(int[] iarr) pure { ... }</div>
<div> int[] marr = foo([1,2,3]);</div><div> // foo will never return the arr argument (without unsafe cast).</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
= "New expression with unique arguments"<br>
-> "Pure new expression ..."<br></blockquote><div><br></div><div>I'm not sure that "pure new expression" is widely used word in D...</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
= (Also, the inadequacy of 'inout' becomes painfully obvious: Clearly,<br>
we'd want 'inout' to mean something different for the source and<br>
target struct instances. Then the definition of what is unique<br>
would not be necessary in this DIP. (Anything that converts to inout<br>
would be fine anyway.))<br></blockquote><div><br></div><div>As I already answered to deadalnix, it is strongly related to inout.</div><div>To describe about that, I added a section "Why use 'inout' keyword for 'unique' postblit?" in DIP.</div>
<div><br></div><div>Kenji Hara</div></div></div></div>