Fully dynamic d by opDotExp overloading

Christopher Wright dhasenan at gmail.com
Sat Apr 18 05:59:48 PDT 2009


Daniel Keep wrote:
>> Cool! I suggest the rewrite:
>>
>> c.unknownmethod(args) -> c.opDotExp!("unknownmethod")(args)
>>
>> That way you have the option of handling the method name statically or
>> dynamically.
> 
> Careful.  If you do that, you need to make sure it's possible to invoke
> a given method at runtime.  Assuming getMembers is implemented (I make
> daily sacrifices in hopes of that), each distinct opDotExpr!(s) needs to
> get an entry.
> 
> Otherwise, you've ironically created something that's HARDER to
> programatically invoke.  :P

Yeah, that's one annoying thing about the proposal. There are a couple 
of solutions:
  - Let types with opDotExp manipulate their type information 
dynamically. This would be a *lot* of work, and it wouldn't necessarily 
work for everything (let's say one instance of the class has some 
methods available and another one has different ones available).
  - Allow template instantiations to be included in type information. 
This will require patching type info again, for instance when you 
compile files separately and instantiate the templates in different modules.



More information about the Digitalmars-d mailing list