<font class="Apple-style-span" face="arial, helvetica, sans-serif">I've found this behavior while toying with opCall() in a struct:</font><div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
<span class="Apple-style-span" style="font-family: 'courier new', monospace; ">import std.stdio;</span><font class="Apple-style-span" face="'courier new', monospace"><br></font><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">struct Struct<br>
</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">{<br></span><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> this(int value) { writeln("Struct.this(", value, ")"); }<br>
</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> ~this() { writeln("Struct.~this()"); }<br></span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">}</span><font class="Apple-style-span" face="'courier new', monospace"><br>
</font><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">void main()<br></span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">{<br></span><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> Struct s = Struct(1); // prints `Struct.this(1)`<br>
</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> s(2); // prints </span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">`</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">Struct.this(2)`</span></blockquote>
<blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> s(3); // prints </span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">`</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">Struct.this(3)`</span></blockquote>
<blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" face="'courier new', monospace">} // prints </font><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">`</span><font class="Apple-style-span" face="'courier new', monospace">Struct.~this()</font><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">`</span></blockquote>
<div><br></div><div>Notice how the destructor is only called once. If there was an opCall defined for Struct, its reconstruction would shadow it. It certainly looks like a bug to me, but since I'm "sure of nothing" in D I decided to post it here. Is it really a bug?</div>
</div><div><div><br></div>-- <br>Atenciosamente / Sincerely,<br>Guilherme ("n2liquid") Vieira<br>
</div>