Destructor semantics

Jonathan M Davis jmdavisprog at gmail.com
Wed Aug 11 10:10:08 PDT 2010


On Wednesday, August 11, 2010 07:08:27 Steven Schveighoffer wrote:
> I agree with what Michael suggested that destructors should be restricted
> to unsafe D.

The more this whole issue gets discussed, the less it seems like I know about 
the issue. It's just too complicated to be immediately understandable. 
Personally, I think that the very fact that it's possible to access references 
which are no longer valid in a class destructor (and not only possible but 
_easily_ as well) makes it so that class destructors should be disallowed in 
SafeD. They just don't sound safe. If you really know what you're doing, you can 
use them, but other than that, forget it. That sounds precisely like why SafeD 
exists in the first place.

Not to mention, it's looking more and more to me like if you want any kind of 
reasonable destruction going on, you need to be using a struct on the stack 
anyway. I'd suggest not only disallowing class destructors in SafeD but also 
disallowing structs with destructors on the heap in SafeD. It's just too messy.

- Jonathan M Davis


More information about the Digitalmars-d mailing list