deprecated delete and manual memory management

Francisco Almeida francisco.m.almeida at gmail.com
Wed Apr 27 00:09:41 PDT 2011


== Quote from Daniel Gibson (metalcaedes at gmail.com)'s article
> Am 27.04.2011 02:03, schrieb Steven Schveighoffer:
> IMHO clear isn't needed for anything but structs and Objects.
> For any simple type or pointer you can just write x = x.init; instead of
> clear(x) or, as you already mentioned, x=null; for pointers.
> AFAIK the main purpose of clear() is to explicitly call the destructor -
> and that only makes sense for structs and classes.
> Allowing it for other types (especially pointers) just sneaks in
> non-obvious bugs, especially when it's considered a replacement for
> delete (which calls the destructor for both Object a *struct).
> BTW: clear() has often been mentioned in this NG but isn't documented in
> the Phobos documentation (which is no surprise because clear() doesn't
> have doc-comments).
> So I guess I'll report this as a bug.
> Cheers,
> - Daniel

Regarding clear(), has the implementation already been corrected so that it does
*not* call the constructor after object destruction?


More information about the Digitalmars-d mailing list