D - destructors
- imr1984 (3/3) Jan 06 2004 As D is a GC language, does that mean that ~this() is kinda redundant, e...
- Andy Friesen (7/10) Jan 06 2004 Destructors are mainly used to deallocate resources that are not under
As D is a GC language, does that mean that ~this() is kinda redundant, except when using auto classes ? When should one use an auto class? In the destructor of an auto class, should all dynamic resources be deleted explicitly ?
Jan 06 2004
imr1984 wrote:As D is a GC language, does that mean that ~this() is kinda redundant, except when using auto classes ? When should one use an auto class? In the destructor of an auto class, should all dynamic resources be deleted explicitly ?Destructors are mainly used to deallocate resources that are not under the GC's thumb. When interfacing with C libraries, for instance, you typically get pointers to structs (or whatever) from the library. Unless the library itself was coded in D, you nede to free it explicitly. Destructors are the place to do it. -- andy
Jan 06 2004