On 2011-09-11 10:23:21 +0000, "Marco Leise" <[email protected]> said:
Is there a reason why the method that calls the destructor hasn't been
called 'deinit', 'destruct', 'invalidate' or 'destroy' instead?
Probably to confuse people.
And are these bug reports in fact invalid as per specification of clear() ?
http://www.digitalmars.com/d/archives/digitalmars/D/bugs/Issue_5816_New_clear_breaks_associative_array_29122.html
http://www.digitalmars.com/d/archives/digitalmars/D/bugs/Issue_5683_New_Calling_.clear_on_a_fresh_associative_array_causes_subsequent_segfault_28632.html
Seems
like they are indeed invalid. Clear is working as intended, and is
confusing people.
I'm confused :p
See, it works!
Enough sarcasm. If I recall, Andrei liked the name 'clear' and was
unsympathetic to the arguments that it'd be confusing. 'clear' is
explained in TDPL and Andrei doesn't like to break his book, so we
might be stuck with that mess for while. But I think it's clear by now
that that 'clear' is confusing and dangerous: it will work with certain
types and completely blow up with others depending on implementation
details of the type (calling the destructor twice, it's insane!). And
the name just make it sounds like it's something pretty normal to do,
which is probably the worse part of it. Actually no, the worse part is
probably that it's inside module 'object', the only module imported by
default everywhere, so you can't even escape the confusion by not
importing its module. :-(
--
Michel Fortin
[email protected]
http://michelf.com/