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

Shachar Shemesh via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 1 23:49:32 PDT 2017


On 02/07/17 02:08, Andrei Alexandrescu wrote:
> Vaguely related question: should "const" convert implicitly to "const 
> shared"? The intuition is that the latter offers even less guarantees 
> than the former so it's the more general type. See 
> http://erdani.com/conversions3.svg.

I don't see how it can. They provide different guarantees. If anything, 
it should be the other way around.

If you hold a pointer to const, you know the data will not change during 
the function's execution. No such guarantees for const shared.

On second thought, aliasing means that the first is not true either. I 
retract the above comment, sending it out on the off-chance someone can 
turn it into a useful insight :-)

Shachar


More information about the Digitalmars-d mailing list