How to call binary functions on primitive on runtime?

Tom no.email at gmail.com
Sat Feb 12 10:49:15 PST 2011


how can I make an implementation of some thing like Foo:
>> assert(Foo("+", 1, 2) == 1+2);
>> assert(Foo("*", 3, 2) == 3*2);
without writing a long switch with case for each operator like:
>> switch (oper) {
>>   case "+": return a+b;
>>   ..
>> }
I know how to implementation a compile-time equivalent with the mixin statement.
thanks.


More information about the Digitalmars-d-learn mailing list