eliminate new operator paraphernalia

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Feb 14 14:21:51 PST 2010


Michel Fortin wrote:
> On 2010-02-14 15:41:30 -0500, Andrei Alexandrescu 
> <SeeWebsiteForEmail at erdani.org> said:
> 
>> Michel Fortin wrote:
>>>
>>> Hum, what's the syntax for placement delete?
>>
>> There is no need for placement delete. There will be a function 
>> clear() in object.d that only calls the destructor. (That is needed 
>> regardless.) You can carry deallocation with your own API functions.
> 
> What's the point in wasting a function name only to call the destructor? 
> Why not just allow "object.~this()"?

You might want to clear an int etc. for which it's unclear whether the 
above should work.

> Also, if you really want to put an object back in it's initial state, 
> you could call both the destructor and the constructor. Anything else is 
> going to break the object's invariant. I think it's best to leave 
> breaking the object's invariants to a special syntax, hence 
> "object.~this()".

Yah, clear destroys and then fills with .init.

Andrei



More information about the Digitalmars-d mailing list