On Thu, 07 Apr 2011 14:20:53 -0400, %u <wfunct...@hotmail.com> wrote:
I was trying to write a "Dynamic" class for D, which uses opDispatch to allow for late binding, but I ran into a problem: While my class works well for regular methods inside a class, it fails to work for: (1) Template methods inside a class (2) Methods with overloads (3) Global methods that have nothing to do with a class, like writeln Furthermore, it would also fail to work for (4) UCFS if/when it's implemented. It seems like templates by design *don't* allow for anything to happen dynamically, and at the same time, it seems like _everything_ is becoming a template nowadays. So my question is, is there anything we can do about it (either now or later)? Or is a dynamic extension simply beyond the reach of D?
I've added reflection capabilities to an update to std.variant I'm working on. Overloads work. General functions work. (Although a few bugs with opCall and opDispatch prevents the ideal syntax: var.x(5) vs var.x = 5 and var.call(5) vs var(5), but I assume those will be eventually fixed). I've also added an internal type database, so you can auto-magically build a Variant(TypeInfo, void*) or Variant(Object) and then call methods on the real, underlying type.
Templates, I think, will out of the range of dynamic D capabilities for some time to come.
Also, because I'm wrapping / unwrapping all arguments, ref doesn't work.