On Tuesday, 27 June 2017 at 23:54:50 UTC, Moritz Maxeiner wrote:

Do you mean destructors?

Yes.


- Replace calls by the GC to `~this` with calls to `finalize` (or invent some cool other shortened name for the latter)

My point is that in such a "finalize()" function the only sane things to do is to crash if the resource wasn't freed already. Why so?

See my texture example in: https://forum.dlang.org/post/[email protected]

More simply:
If A needs an alive B to be destroyed, then neither A-owns-B or B-owns-A can guarantee the ordering under GC destruction.

Furthermore, this is viral. Whoever owns A needs an alive B to be destroyed.



- Reserve `~this` for being called by deterministic lifetime management (std.experimental.allocator.dispose, object.destroy, RefCounted, Unique, etc.)

That's precisely what the GC-proof-resource-class allows, by preventing defective, non-composable usages of ~this.

Reply via email to