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

Vladimir Panteleev via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 2 03:31:06 PDT 2017


On Sunday, 2 July 2017 at 09:15:45 UTC, Walter Bright wrote:
> On 7/1/2017 3:12 PM, Timon Gehr wrote:
>> It used to be the case that const(inout(T)) = const(T),
>
> Anyone want to run git bisect and see when this changed? This 
> would help in figuring out the rationale.
>
> Here's the code to test with it:
>
> inout(const char)* foo(inout(const(char))* p)
> {
>     pragma(msg, typeof(p));
>     static assert(is(typeof(p) == const(char)*));
>     return p;
> }

This code doesn't compile in any version going as far back as 
2.038, and before that one this code gets a syntax error.

This line:

static assert(is(const(inout(int)) == const(int)));

stops working after:

https://github.com/dlang/dmd/pull/2992

The same pull request changes the type of p in the above example 
from inout(char)* to inout(const(char))* (it was never 
const(char)*).



More information about the Digitalmars-d mailing list