Have a look at the following code:

class Foo
{
    static Foo instance_;

    static Foo instance ()
    {
        if (instance_)
            return instance_;

        return instance_ = new Foo;
    }

    static auto opDispatch (string name, Args...) (Args args)
    {
        mixin("return instance." ~ name ~ "(args);");
    }

    void bar () {}
}

void main ()
{
    Foo.bar;
}

Compiling the above code results in:

Error: need 'this' to access member bar

Is it possible somehow to make the above code compile? If not, could the compiler be changed to make the above code compile?

--
/Jacob Carlborg

Reply via email to