Blog: GC

Rumbu rumbu at rumbu.ro
Sat Mar 6 21:12:51 UTC 2021


On Saturday, 6 March 2021 at 20:45:00 UTC, Adam D. Ruppe wrote:
> 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.

A library solution is not a feature of the language. Also the 
scope Object declaration is not needed. At least I didn't found 
any reference in the language specification except the one of 
scoped classes, which, of course, will be deprecated.



More information about the Digitalmars-d mailing list