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.

Why were things changed that way ?

On Oct 28, 2015 15:33, "Andrei Alexandrescu" <andrei@erdani.com> wrote:
On 10/28/2015 04:39 PM, deadal nix wrote:
Andrei, to quote you :
"[...]at least in v1.0 we're considering having the callER do the
increment and the callEE do the decrement. This is how D currently
handles copy construction and destruction, and it turns out it has a
number of advantages over C++ (where the caller does all the work)."

Can you explain how C++ and D destructor management differs, and what
are the rationale behind these differences ?

Not much of the place here, but in brief in C++ consider the call:

class C { ... };
void fun(C);
int main() { C obj; fun(obj); }

In the call to fun, the callER calls the copy ctor of C, invokes fun, then calls the dtor of C.

In D, the callER calls the copy ctor, but it's the callEE that calls the dtor.


Andrei
_______________________________________________
Dlang-study mailing list
Dlang-study@puremagic.com
http://lists.puremagic.com/cgi-bin/mailman/listinfo/dlang-study