Dynamic alter-ego of D.

Adam Ruppe destructionator at gmail.com
Wed Oct 26 07:25:54 PDT 2011

You can use opDispatch to make runtime methods and properties
by having it forward to a function to do the lookup.

Something alone these lines:

DynamicObject delegate(DynamicObject[] args) dynamicFunctions;

DynamicObject opDispatch(string name, T...)(T t) {
      if(name !in dynamicFunctions) throw new MethodNotFoundException(name);
      DynamicObject[] args;
      foreach(arg; t)
           args ~= new DynamicObject(arg);

      return dynamicFunctions[name](args);

I've done a more complete implementation before, but don't have
it on hand right now.

More information about the Digitalmars-d mailing list