Why can't we define re-assignable const reference variable?
none
z at gg.com
Sat Feb 16 18:33:41 PST 2008
Actually we can rebind already: this is legal code accepted by the DMD compiler
for (i = n; i-- > 0; ) {
const B b = getConstB(i); // are we rebind here n-times already?
b.doSomething();
}
// the trouble is I cannot use the last 'b' i.e. getConstB(0),
// anymore, it will be out of scope
b.doSomethingElse();
> (as we do now), I can always get around it by using D pointers:
> const(B)* b; // type change
> b = &b1; // rebind
> b = &b2; // rebind
> It's just so inconvenient, that's why I suggest allow define re-assignable const
> reference variable.
More information about the Digitalmars-d
mailing list