On 8/4/12 4:45 AM, Jonathan M Davis wrote:
D needs to work well with const, but one of the goals is also to make it so that it's not required if you don't want to or can't use it. Forcing invariants to be const goes against this. But that decision was probably made before the recent decisions on Object and const functions (i.e. that toString, toHash, opCmp, and opEquals will no longer be part of Object, so you'll be able to make them whatever constness you want), and I expect that it'll be reverted as long as it's appropriately pointed out to Walter (though it may require someone else creating a pull request with the actual changes).
My opinion in the matter is that invariants are meant to be gatekeeper code that makes sure things stay sane and bug-free. Such code should have special exemptions, much like the debug statement does. Protecting invariants against their own bugs seems a bit extreme to me.
I think a stance could be taken either way. Const invariants are like the European police; non-const invariants are like US police.
Andrei
