interface IFoo {
        void a();
        void b();
}

__gshared IFoo a, b;
__gshared IFoo instance;

class Foo(bool bar) : IFoo {
        void a() {
                static if (bar) {
                        // do something
                } else {
                        // do nothing
                }
        }
}

shared static this() {
        a = new Foo!true;
        b = new Foo!false;
}

void update(Lookup lookup) {
        if (lookup["bar"])
                instance = a;
        else
                instance = b;
}

Small indirection when executing to find which function to execute but that is the best out of language semantics we have and only works for booleans.

Reply via email to