invariant constancy: revisited

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Mar 15 04:34:16 PDT 2014


On 3/14/14, Jakob Ovrum <jakobovrum at gmail.com> wrote:
> Back in 2012, invariants were misguidedly made const by default
> without going through any review whatsoever, breaking a ton of
> code in the process[1].

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.


More information about the Digitalmars-d mailing list