It's worse than I thought

Janice Caron caron800 at googlemail.com
Fri Nov 30 03:06:53 PST 2007


On Nov 30, 2007 10:52 AM, Walter Bright <newshound1 at digitalmars.com> wrote:
> It turns out that making a variable that is typed const (rather than
> storage class const) immutable makes it impossible to use const references:
> So, variables that are typed const are rebindable.

Yes, there is another thread on that somewhere. It's got some long
arguments in it, which it would be silly to repeat here, but in the
end I proposed the syntaxes:

    const(C) c;
    const(C) ref c;

The first makes both the reference and the data const; the second
makes only the data const, but the reference rebindable. (Other people
have suggested alternative syntaxes through the ages, so don't think
I'm particularly hung up on mine, it's just that it seems very clear
what's being said).


> Note that this
> doesn't break const

Nobody's saying anything is broken. What I'm saying is that it's TOO
CONFUSING. This can break D. I mean, on other threads, you told us
that "const X x" was the same thing as "const(X) x". Now it turns out
that's not true.

The only, and I mean *ONLY*, thing that makes intuitive sense, is that
when I write const(...), it must mean that everything inside the
brackets, and nothing else, is const. Nothing else makes sense.



More information about the Digitalmars-d mailing list