On 01.07.2017 23:47, 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?

I don't think so.

Is there a need for combining const and inout?
...

In DMD's implementation, yes. (Combinations of qualifiers are represented as integers instead of nested AST nodes.)

const(const(T))     = const(T)
const(immutable(T)) = immutable(T)
const(inout(T))     = ?

It used to be the case that const(inout(T)) = const(T), but this is wrong, because if we replace 'inout' by 'immutable', the result should be immutable(T), not const(T). Hence const(inout(T)) cannot be reduced further.

The simplified hierarchy is enough though. The more complex one can be derived from it. Since S -> const(S) for all S, it directly follows that inout(T) -> const(inout(T)) for all T (we can choose S=inout(T)).

Reply via email to