clear() and UFCS

Michel Fortin michel.fortin at michelf.com
Sat May 26 07:39:11 PDT 2012


On 2012-05-26 12:00:15 +0000, Jacob Carlborg <doob at me.com> said:

> On 2012-05-26 03:38, Jonathan M Davis wrote:
> 
>> clear and delete are very different things. It was definitely decided that we'd
>> be better off without delete. It's going for good. Renaming clear to something
>> that doesn't conflict so easily with more benign functions is completely
>> different from bringing back delete. Bringing back delete isn't even on the
>> table at this point.
>> 
>> - Jonathan M Davis
> 
> Why can't "delete" do what "clear" does. Backwards compatibility?

That'd be my preferred solution too. I think it makes a lot of sense. 
Clear does almost the same thing as delete, except that currently 
delete means memory can be reused immediately, which is not safe. If 
the only difference is that one is safe and the other is not, and if 
we're going to deprecate and then remove delete because it's not safe, 
wouldn't it make more sense to simply make 'delete' memory-safe by 
giving it the semantics of clear()?

By the way, clear() as "clear" would have made more sense if it was 
effectively destructing then reconstructing the object in place, making 
it a suitable default implementation of the container-kind clear(). But 
for what it does right now, it's *clearly* misleading.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list