<p dir="ltr">I think it is very relevent here as destructor is a very common tool to free resources, as well as one of the most complex to deal with, mostly because of move semantic. I already had in mind to launch that subject before this whole thing started.</p>
<p dir="ltr">Why were things changed that way ?</p>
<div class="gmail_quote">On Oct 28, 2015 15:33, "Andrei Alexandrescu" <<a href="mailto:andrei@erdani.com">andrei@erdani.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 10/28/2015 04:39 PM, deadal nix wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Andrei, to quote you :<br>
"[...]at least in v1.0 we're considering having the callER do the<br>
increment and the callEE do the decrement. This is how D currently<br>
handles copy construction and destruction, and it turns out it has a<br>
number of advantages over C++ (where the caller does all the work)."<br>
<br>
Can you explain how C++ and D destructor management differs, and what<br>
are the rationale behind these differences ?<br>
</blockquote>
<br>
Not much of the place here, but in brief in C++ consider the call:<br>
<br>
class C { ... };<br>
void fun(C);<br>
int main() { C obj; fun(obj); }<br>
<br>
In the call to fun, the callER calls the copy ctor of C, invokes fun, then calls the dtor of C.<br>
<br>
In D, the callER calls the copy ctor, but it's the callEE that calls the dtor.<br>
<br>
<br>
Andrei<br>
_______________________________________________<br>
Dlang-study mailing list<br>
<a href="mailto:Dlang-study@puremagic.com" target="_blank">Dlang-study@puremagic.com</a><br>
<a href="http://lists.puremagic.com/cgi-bin/mailman/listinfo/dlang-study" rel="noreferrer" target="_blank">http://lists.puremagic.com/cgi-bin/mailman/listinfo/dlang-study</a><br>
</blockquote></div>