On 23.06.2016 14:58, Steven Schveighoffer wrote:
On 6/21/16 5:19 PM, Timon Gehr wrote:


The problem here is that both variants make sense depending on context
and there is no syntax to distinguish between them. This proposal
interacts in a weird way with IFTI.

I know you are probably right, but can you explain maybe via an example
what you mean? I'm not understanding your point.

-Steve

One might legitimately want to pass a inout delegate to some inout function and then use the delegate on data with arbitrary mutability qualifiers, not just inout.


The IFTI comment was about for example something like this:

struct S{
    void bar(inout int){}
    void foo(T)(T arg)inout{
        // this looks like it can be called with any argument
        arg(&bar);
    }
}

void main(){
    immutable(S) s;
    void delegate(void delegate(inout(int))) dg = x=>x(2);
    s.foo(dg); // today, this works
    // with the proposed semantics, IFTI deduces
    // T = void delegate(void delegate(inout(int)))
    // but then cannot convert dg to a T after
    // inout resolution
}

But I don't feel strongly about which of the two variants it should be. It's weird either way, as long as there can be only one inout in scope.

Reply via email to