Blog: GC

Adam D. Ruppe destructionator at gmail.com
Sat Mar 6 21:48:05 UTC 2021


On Saturday, 6 March 2021 at 21:12:51 UTC, Rumbu wrote:
> A library solution is not a feature of the language.

I'm not talking about a library solution.

> Also the scope Object declaration is not needed.

That's how you get scoped, deterministic destruction of class 
objects in the pure language.

> At least I didn't found any reference in the language 
> specification except the one of scoped classes, which, of 
> course, will be deprecated.

That's different. That's what I meant by `scope class`, but 
`scope Object` is referring to it as a storage class

https://dlang.org/deprecate.html#scope%20as%20a%20type%20constraint

"scope as a storage class attributed to variables, function 
parameters, etc. is not deprecated."

But this is why it is complicated: as the class author, you can't 
know how it will be used. The same is also true of structs, which 
the next part of the blog will talk about. So you need to take 
some appropriate care.

It can be done right though.


More information about the Digitalmars-d mailing list