deprecated delete and manual memory management

Steven Schveighoffer schveiguy at yahoo.com
Wed Apr 27 06:00:01 PDT 2011


On Wed, 27 Apr 2011 03:09:41 -0400, Francisco Almeida  
<francisco.m.almeida at gmail.com> wrote:

> == 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?

It's fixed in the latest git repository (BTW, how does one refer to the  
git "trunk"?)

It's not in 2.052

-Steve


More information about the Digitalmars-d mailing list