Why can't we define re-assignable const reference variable?
Sergey Gromov
snake.scaly at gmail.com
Wed Feb 20 10:39:41 PST 2008
Steven Schveighoffer <schveiguy at yahoo.com> wrote:
> "Sergey Gromov" wrote
> > If you create a generic algorithm which works with T, and declare
> > something as
> >
> > const(T) t;
> >
> > then you effectively assert that you're going to replace t with
> > different other Ts, but promise to keep integrity of a referenced T
> > intact, if anything is referenced at all. This means that for int,
> > which is not referencing anything,
> >
> > const(int) t;
> >
> > is completely and safely equivalent to
> >
> > int t;
> >
> > without breaking any contracts of your algorithm. Please provide an
> > example where "const(int) x;" absolutely must mean "const int x;" for a
> > generic algorithm to work properly.
>
> Sergey, I am not arguing that the functionality that you wish to have is
> invalid. In fact, I would have been ok with that syntax, and understood it
> once it was explained thoroughly. But I have to say that I agree with
> Janice and Walter on this one, it was very confusing.
>
> It just goes against the traditional usage of parentheses. The idea is
> correct, the syntax is confusing. Find another syntax.
The traditional usage of parentheses is this: foo(x). This means that a
function foo is applied to its argument x, and not applied to everything
else. You are probably talking about some different tradition. Please
clarify.
--
SnakE
More information about the Digitalmars-d
mailing list