On 7/26/17 2:33 PM, Moritz Maxeiner wrote:
On Wednesday, 26 July 2017 at 17:38:28 UTC, Dgame wrote:
I don't get it. The GC collects the objects which aren't in use
anymore. The order in which this is currently happening is not
specified. So, how are the destructors supposed to be called in the
right order? Manually? ARC?
After the split:
Destructors are only for deterministic end of object lifetime, so yes,
they are to be called by any scheme (such as manual management via
destroy and reference counting - which is likely also implemented as
calling destroy) that is deterministic.
Finalizers are for nondeterministic schemes such as the GC.
The GC *never* calls destructors directly, only finalizers.
A finalizer might manually call a destructor, but a destructor may never
call a finalizer.
Actually, it's the opposite. A finalizer can never call anything on its
members because it doesn't know if it's being destroyed by the GC.
The destructor is ensured that the entire structure is intact, so it can
do whatever it wants.
-Steve