<div dir="ltr"><div>With 2.063, this code would work.</div><div><br></div><div>struct S { int* ptr; } // has mutable indirection</div><div><br></div><div>void main()</div><div>{</div><div> immutable S si = function () pure</div>
<div> {</div><div> S sm;</div><div> sm.ptr = new int;</div><div> *sm.ptr = 10;</div><div> return sm; // construct and return mutable object</div><div> }();</div><div> static assert(is(typeof(*si.ptr) == immutable int));</div>
<div> assert(*si.ptr == 10);</div><div>}</div><div><br></div><div style>The local function would return an unique object, so it is implicitly convertible to immutable.</div><div style><br></div><div style>Kenji Hara</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/5/29 Jakob Ovrum <span dir="ltr"><<a href="mailto:jakobovrum@gmail.com" target="_blank">jakobovrum@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Wednesday, 29 May 2013 at 12:40:39 UTC, Dicebot wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Why something like this is not usable?<br>
-----------------------<br>
int tmp;<br>
try<br>
{<br>
tmp = ...;<br>
}<br>
catch(..)<br>
{<br>
}<br>
const(int) i = tmp;<br>
-----------------------<br>
Not really pretty but nothing crazy.<br>
</blockquote>
<br></div></div>
const(int) i = tmp; // fails when the type has mutable indirection.<br>
</blockquote></div><br></div>