invariant constancy: revisited

Jakob Ovrum jakobovrum at gmail.com
Sat Mar 15 08:05:14 PDT 2014


On Saturday, 15 March 2014 at 14:46:13 UTC, Daniel Murphy wrote:
> "Andrej Mitrovic"  wrote in message 
> news:mailman.134.1394883267.23258.digitalmars-d at puremagic.com...
>
>> How about a compromise based on Andrei's new final(bool) 
>> suggestion?
>> We could implement const(false) to allow overriding the default
>> behavior of invariants. E.g.:
>>
>> class C
>> {
>>    invariant()  // const-by-default, as usual
>>    {
>>    }
>>
>>    invariant() const(false) // new feature
>>    {
>>    }
>> }
>>
>> That way existing code stays safe.
>
> Yuck.  We can always warn for a while on invariants not 
> explicitly marked as const, if we're worried about breakage.
>
> You should be able to use most of the language without using 
> const, making invariants implicitly const was a bad idea.

I agree. Implicit const was only in play for a few releases; a 
couple of releases of deprecation time should be plenty, 
especially considering the number of users who have been unable 
to use invariants in those releases.


More information about the Digitalmars-d mailing list