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

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 2 11:49:29 PDT 2017


On 7/2/2017 6:33 AM, Timon Gehr wrote:
> The best way to think about inout is that it enables a function to have three 
> distinct signatures:
> 
> inout(int)[] foo(inout(int)[] arg);
> 
> "expands" to:
> 
> int[] foo(int[] arg);
> immutable(int)[] foo(immutable(int)[] arg);
> const(int)[] foo(const(int)[] arg);
> 
> 
> const inout /does not change this in any way/:
> 
> 
> const(inout(int))[] foo(inout(int)[] arg);
> 
> expands to:
> 
> const(int)[] foo(int[] arg);
> const(immutable(int))[] foo(immutable(int)[] arg);
> const(const(int))[] foo(const(int)[] arg);

Thank you. This explanation makes sense (given that applying const to immutable 
=> immutable).


More information about the Digitalmars-d mailing list