On 10/26/2010 18:00, bearophile wrote: > All this looks bug-prone, and surely hairy, but it looks potentially > useful. Is it a good idea to design a class that uses such temporary > suspension of the invariant?
I think invariants should be checked whenever a public member function is called from outside the object. If setting the object to an invalid state from outside is valid, then clearly the state isn't really invalid. On the other hand, if the object itself calls it own public member functions, then no invariants should be checked. Not being able to call public member functions while the object is temporarily in an invalid state is too strict. This is a problem that I actually ran into while using D, and one of the reasons for why I stopped using invariants. -- Rainer Deyke - rain...@eldwood.com