unpaintable (the solution to logical const)
Janice Caron
caron800 at googlemail.com
Fri Apr 4 11:09:43 PDT 2008
On 04/04/2008, Simen Kjaeraas <simen.kjaras at gmail.com> wrote:
> What reason would exist for having an unpaintable invariant field? As far
> as I've understood, invariant is implicitly castable to const
So is mutable.
I don't know what the uses would be. C++ doesn't have it. No language
that I'm aware of has it. This is new. Like mixins - when they were
first introduced, Walter said words to the effect of "I've no idea
what these things will be used for, but they might be useful, so let's
wait and see".
No one is suggesting there is a specific need to create permanently
invariant fields, but people /are/ suggesting we need logical const,
and this is a solution (...and so far as we are aware, the /only/
solution...) that works. That it gives us unpaintable invariant fields
as a side-effect is an interesting bonus.
> and casting
> away const/invariant is a Bad Thing,
Right - which is why this scheme specifically avoids any need to do
that. Everything is tightly constrained.
> so whether it is const or invariant
> does little difference, except for functions that demand invariant
> arguments.
And there may well be those - especially when it comes to pure functions.
More information about the Digitalmars-d
mailing list