On Wednesday, 26 July 2017 at 09:29:15 UTC, Moritz Maxeiner wrote:


As class destructors (in contrast to class finalizers) are then called exclusively in a deterministic fashion, there's no reason to forbid them from allocating using the GC, so I don't think using the @nogc attribute would be appropriate; I would much rather see another attribute in the likes of @disable, e.g. @deterministic, so
---
~this() {}                    // Finalizer
~this() @nogc {}              // Finalizer
~this @deterministic {}       // Destructor
~this @nogc @deterministic {} // Destructor
}

Yeah, this brings with it more flexibility. I'd prefer to avoid adding a new attribute for it, but this looks more interesting.


When cleaning up, the GC will ensure that all destructors are run where they exist, followed by all finalizers.

Having the GC directly call destructors defeats the point of separating them from finalizers in the first place:

Indeed! Let's pretend I didn't write that.

Reply via email to