On 2010-08-09 21:20:31 -0400, Andrei Alexandrescu <[email protected]> said:

clear() would not subvert the type system.

Oh sure it does!

1. You acknowledged yourself one of my argument a few days ago that if the class has an immutable member it'll be wiped out. Someone else somewhere could have a reference to that member, and it's value will change which could cause bad things...

2. If someone somewhere has a reference to an object, clearing that object is basically the same as replacing that reference with a reference to a new, uninitialized object. This could break invariants of any code still using that reference. In normal times, those invariants could be protected with judicious usage of 'private', 'protected' or 'package' in the object (or something more sophisticated), but all that gets subverted by clear().

So clear() can have long-reaching effects (break program invariants) if used at the wrong place, and it's difficult to protect against people using it at the wrong place.

I know for one thing that clearing any object used by the D/Objective-C bridge is a potential crasher (if you call a function on a cleared wrapper). I would suspect the same for QtD.

--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to