Why can't we define re-assignable const reference variable?

Janice Caron caron800 at googlemail.com
Wed Feb 20 10:49:13 PST 2008


On 20/02/2008, Sergey Gromov <snake.scaly at gmail.com> wrote:
>  > I mean, it was just too confusing for words. No way
>  > can we /ever/ go back to that. For any type, T, const(T) absolutely
>  > /must/ mean that T is const.
>
> My concept is very simple.  Everything within the scope of const is
>  const, everything outside is not.

Not good enough. Everything inside the /brackets/ must be const.
Otherwise, don't call it const, call it something else. Call it
"tailconst" or "rebindable" or whatever, but don't call it const,
because it isn't.

I want to be able to introduce newbies to D and tell them how
wonderful it is. I can't do that if const(T) doesn't mean const T.
Really.

Back it D2.007 - the version of const that you like, but most people
didn't, we had five different kinds of const. Count them. Five. They
were:

    final T // head const
    const(T) // tail const
    const T // fully const
    invariant(T) // tail invariant
    invariant T // fully invariant

...and that's not counting the use of "in" in function declarations.
It was just too silly for words.

Right now, in D2.011, "invariant(char)[]" is a string. That makes
absolutely perfect sense. Long may that remain.

What is your problem with just choosing a different word, or a
different syntax? You'd get a lot more support for the idea that way.
I certainly wouldn't be arguing with you in that case.



More information about the Digitalmars-d mailing list