syntax question on "invariant" keyword
michael.kiermaier at gmx.net
Wed Jul 4 04:15:25 PDT 2007
> Are you using dmd 1.x ? The final-const-invariant thing only works on
> the experimental 2.x version. I tried your example there and it compiles
> without errors as expected.
Well, that seems to be the problem:
My dmd command reports:
Digital Mars D Compiler v1.018
Where can I get the 2.x version? I cannot find it in the "download" section on the Digitalmars D hompage
And what exactly is the status of 2.x? I believe I read somewhere, that D 2.0 was officially released. But now you write that it is still experimental.
> "invariant(int) x" this is useless and does not mean that x can't be
> changed, what someone might think at first.
> Using brackets means that you can assign another instance of TYPE to the
> variable. But you can't change the data of the instance.
> "invariant(int) x" means: you can assign another instance of int to x
> You see, this doesn't make sense.
> It's equal useless for all simple storage classes.
> However, "final invariant(int) x = 1" works like "invariant int x = 1",
> because final means: you can't assign another int to x
Thanks for the explanation!
More information about the Digitalmars-d-learn