Dynamic alter-ego of D.

Steven Schveighoffer schveiguy at yahoo.com
Wed Oct 26 07:26:17 PDT 2011

On Wed, 26 Oct 2011 10:15:33 -0400, Gor Gyolchanyan  
<gor.f.gyolchanyan at gmail.com> wrote:

> 1. opDispatch is no good for overloading when the set of methods are
> defined at run-time.

For those cases, you must use the runtime interface that opDispatch will  
use directly.  D does not have a way to call a function by string at  

call("functionName", arg1, arg2, arg3)

opDispatch simply provides a way to write cleaner code when you know the  
name of the function.

Even in dynamic languages, it's uncommon to call functions based on  
runtime strings.

> 2. opDIspatch doesn't cover operators (why?).

operators are not function symbols, and are already covered by templates.   
It should be as simple as:

opBinary(string s, T...)(T args) if(isValidOperator!s)
    call(s, args);


More information about the Digitalmars-d mailing list