January 06, 2004 destructors | ||||
---|---|---|---|---|
| ||||
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 ? |
January 07, 2004 Re: destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to imr1984 | 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
|
Copyright © 1999-2021 by the D Language Foundation