Blog: GC

Adam D. Ruppe destructionator at gmail.com
Sat Mar 6 20:45:00 UTC 2021


On Saturday, 6 March 2021 at 20:21:41 UTC, Rumbu wrote:
> It seems that the author failed to update himself or - what's 
> worse - wants to justify D failure in having deterministic 
> class destruction by pointing to others.

D *does* have deterministic class destruction. `scope Object o = 
new Object;`. Also `scope(exit) .destroy(o);`.

The blog is kinda awkward because it says "pretend class 
destructors don't exist" now, but the next parts are going to 
explain how he's lying to you.

Class destructors do exist in D, just you need to take care to 
use them properly (especially since the old `scope class` was 
deprecated. Note this is distinct from the not-deprecated `scope 
Object` construct.). So the early advice is to pretend they don't 
exist. Then once you level up a little you can learn the truth.


More information about the Digitalmars-d mailing list