I'm currently working on a IReflectionable interface

Currently the usage is as follows

class Foo : IReflectionable
{
  mixin ReflectionImpl;

  void bar(int a) { /* do something */ }
  int baz(string a) { return a.length; }

}

unittest
{
   IReflectionable foo = new Foo();

   alias void delegate(int) bar_t;

auto bar = foo.funcPtr!(bar_t, "bar"); //Gets a delegate to foo.bar
   bar(1); //Calls foo.bar(1);

   alias int delegate(string) baz_t;
   auto baz = foo.funcPtr!(baz_t, "baz");
   int a = baz("Hello");
}

Now this works and is all well and good. However i would like to improve on the
syntax a bit.

This is how i would like to call the code.

unittest
{
  IReflectionable foo = new FooService();

  foo.bar(1); //Now this becomes foo.opDispatch!("bar", int)(1);

int a = foo.baz("Hello"); //This does NOT work. Cannot figure out returntype
}

The problem i am faced with is that i need a way to figure out the return value of opDispatch by the invokation call.

all the information i need is here

int a = foo.baz("hello");

This gives returntype int.

So is there a way to gain this information in opDspatch? Is it possible to do something like this?

auto a = foo.baz!(int)("hello");







Reply via email to