Why can't we define re-assignable const reference variable?
    Christopher Wright 
    dhasenan at gmail.com
       
    Sat Feb 16 18:32:53 PST 2008
    
    
  
none wrote:
> == Quote from Janice Caron (caron800 at googlemail.com)'s article
>> On 16/02/2008, none <z at gg.com> wrote:
>>>  So why can't we have both (just as in C++):
>> This has been covered so many times before, but in summary, allowing
>> that would completely break the type system.
> 
> I don't understand why it will break the type system; in any case, even without it
> (as we do now), I can always get around it by using D pointers:
 From Walter's perspective, there are a few choices:
- First-class references. A large language feature to solve a small problem.
- Do nothing.
- Have Andrei cook up a library solution.
For that last, you can't simply put a struct around it and go on your 
merry way. The closest you can reasonably come is:
struct Tailconst(T) {
    T t;
    void opAssign(T value) { t = value; }
    // insert method and operator forwarding here
}
    
    
More information about the Digitalmars-d
mailing list