On Tuesday, 8 May 2012 at 22:58:07 UTC, Namespace wrote:
In my development of the Ref / NotNull structure, I came across a
problem: All the methods of "Proxy" aren't "inout". Has this a
reason or will change? In my opinion they should all be "inout".
I mentioned previous self fixes in my corresponding "Ref /
NotNull" thread already.

It is necessary. See following conceptual code:

struct S
{
    void f() {}
    void g() {}
}
struct Proxy(T)
{
    T o;
    void f()() inout { return o.f(); }
    void g(this T)() { return o.g(); }
}
void main()
{
    Proxy!S p;
    //p.f();  // inside Proxy.f, typeof(o) == inout
    p.g();
}

'Proxy' object should forward its 'this' type to original object.
For the purpose, TemplateThisParameter ('this T') works as expected.

Kenji Hara

Reply via email to