eliminate new operator paraphernalia

Jonathan M Davis jmdavisProg at gmail.com
Sun Feb 14 16:33:39 PST 2010


Andrei Alexandrescu wrote:

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

How about reinit()?. clear() seems like a name which people would definitely 
want to use in their own code. The STL uses it for its containers, and you'd 
then have to come up with a new name for that functionality in any container 
classes in D. A name which is less likely to be sought after by programmers 
for their own classes would be better. reinit() is just what comes to mind 
for me, but I think that it would be a shame to lose clear() to Object.

- Jonathan M Davis



More information about the Digitalmars-d mailing list