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

Janice Caron caron800 at googlemail.com
Sun Feb 17 23:12:08 PST 2008


On 18/02/2008, Sergey Gromov <snake.scaly at gmail.com> wrote:
> When I write, "const(C) x;", I mean, "C is const but x is not."

That's just not getting it. x has type const(C), therefore x is const.

I say again, there is no way to express "mutable reference to const
data" in D, and any method you come up with to allow that would be (a)
incredibly confusing, and (b) would break generic programming and/or
the type system.

And ... you never need to do that anyway. There's always a different
way of writing the code.



More information about the Digitalmars-d mailing list