Why can't we define re-assignable const reference variable?
Sergey Gromov
snake.scaly at gmail.com
Tue Feb 19 15:03:59 PST 2008
Yigal Chripun <yigal100 at gmail.com> wrote:
> i suggest the following:
> const(T) t = new T(); // this would be a mutable ref to const T
> const(ref T) t = new T(); // this would be a const ref to const T
> and you can also define "const T" as a shortcut for "const(ref T)"
> i know that this means const(T) isn't the same as "const T" but I think
> that this is a reasonable compromise (if it's consistent for all types)
> another issue with refs is that i want to be able to return the lvalue
> by specifying the return type to be ([const] ref T).
Please, why invent new syntax ?
const(T) t; // mutable ref to const T
const{T t;} // const ref to const T, because of transitiviness
This syntax even worked in one of the previous compiler versions!
--
SnakE
More information about the Digitalmars-d
mailing list