I asked on SO question about opDispatch and compile time parameters: http://stackoverflow.com/questions/32998781/opdispatch-and-compile-time-parameters

Currently it looks like it is not possible to use opDispatch for non trivial template functions. I think opDispatch should get function name plus evaluated compile time arguments as first compile time parameter. E.g not just function name "b", but "b.p2!(int, 10)" See example from SO question:

import std.stdio;

class B{
    auto p1(T)(T arg) {
        writeln( "p1: ", arg );
    }
    auto p2(T, int C)(T s) {
        writeln( "p2: ", s, " / ", C);
    }
}

class C(T) {
    T b = new T;

    auto opDispatch(string s, Args...)(Args args) {
       mixin("b."~s)(args);
    }
}

void main() {
    auto b = new C!(B)();
    //fine: compiler is smart enough
    b.p1("abc");
    //oops: "no property 'p2' for type ..."
    b.p2!(int, 10)(5);
    auto origB = new B;
    //fine:
    origB.p2!(int, 10)(5);
}

Is it good idea for opDispatch improvement or may there is some other approach?

Reply via email to