Why do "const inout" and "const inout shared" exist?

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 1 15:16:12 PDT 2017


On 02.07.2017 00:10, Stefan Koch wrote:
> On Saturday, 1 July 2017 at 21:47:20 UTC, Andrei Alexandrescu wrote:
>> Walter looked at http://erdani.com/conversions.svg and said actually 
>> "const inout" and "const inout shared" should not exist as distinct 
>> qualifier groups, leading to the simplified qualifier hierarcy in 
>> http://erdani.com/conversions-simplified.svg.
>>
>> Are we missing something? Is there a need for combining const and inout?
>>
>>
>> Thanks,
>>
>> Andrei
> 
> inout is bascially the same as const for all parctical purposes.

struct S{
     int x;
     ref inout(int) foo()inout{
         return x;
     }
}

void main(){
     S s;
     s.foo()++; // ok!
     const(S) t = s;
     import std.stdio;
     writeln(t.foo());
     // t.foo()++; // error
}


More information about the Digitalmars-d mailing list