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

Janice Caron caron800 at googlemail.com
Sun Feb 17 13:23:46 PST 2008


On 17/02/2008, Matti Niemenmaa <see_signature at for.real.address> wrote:
> Now what he wants is to convert the C++ "const C* b = a;" to D "??? b = a;" with
> the semantics that b can be reassigned but the data behind it is unchangeable.

OK, I see that.

But the thing is, it is never actually /necessary/ to do that. It is
always possible to just write the code differently. There is really no
pressing /need/ for "const class with mutable reference", since nobody
has ever demonstrated a real-life use case that couldn't just be done
differently. Certainly, no need pressing enough to demand a major
change to generic programming and the type system.

Also, remember that a C++ class is a D struct, and there's really no
equivalent to a D class in C++.



More information about the Digitalmars-d mailing list