TDPL: Manual invocation of destructor

Michel Fortin michel.fortin at
Tue Aug 10 07:11:21 PDT 2010

On 2010-08-10 08:11:21 -0400, "Steven Schveighoffer" 
<schveiguy at> said:

> Undefined, undefined, undefined :)

So we agree on that. That's exactly what I was trying to prove to 
Andrei. Using clear() can break program invariants, break the type 
system (immutable members) and so on, even though I admit it can be 
useful at times.

**** So why give it a so innocuous-looking name such as "clear" !! ****

Call it destroy() at the very very least, and put it in a module where 
no one will find it by accident and think it is safe for general use. 
For instance, it could be made part of the GC API, allowing the GC to 
adjust the memory block to avoid calling the destructor a second time 
upon collection. GC.destroy() sounds like a good name for that kind 

Michel Fortin
michel.fortin at

More information about the Digitalmars-d mailing list