Remix.run Logo
Joker_vD a day ago

> Invariants are functions that run at the start and end of every public member function, and can be used to ensure that the type is always in a valid state.

The ironic thing about this is that it means that the public functions of an object can't, generally, call each other willy-nilly unless they take special precautions: very often, the object's invariants are broken when the execution is in a middle of the object's method. This is not a problem with D, the language merely helps you to uncover this lurking problem which usually simply goes unnoticed until something breaks and someone notices it.

WalterBright 3 hours ago | parent [-]

Yes, a subtle but very important point!