How to write a proper class destructor?

kris foo at bar.com
Thu Jan 25 01:09:19 PST 2007


Bradley Smith wrote:
> According to the documentation, a class destructor is "expected to 
> release any resources held by the object."[1] However, if resources to 
> be released are in objects to be garbage collected, "those references 
> are no longer valid."[1]
> 
> How is a class supposed to release something for which it no longer has 
> a valid reference?
> 
> 
>   Bradley
> 
> 
> 
> [1] http://www.digitalmars.com/d/class.html#destructors.

Yeah, that's a good one :)

Tango has a good resolution for this, that stemmed from long discussion 
on the NG. Those changes never made it into phobos, IIRC


More information about the Digitalmars-d-learn mailing list