
Joel de Guzman wrote:
I'm quite sure that the common ground is the low level (dynamic) 'object' mechanism. There's fine detail going on here such as dealing with type promotion (e.g. int to real), multiple dispatch (e.g. how to deal with, say int+real, bignum+int), etc.
When I finish implementing overloads library, I'm going to add multimethods to dynamic_any. My current vision of it is below: struct plus : operation<plus, anyT(anyT const&, anyT const&)> { template<class OperationList> struct definition { definition(plus) {} int operator()(id<1>, int a, int b) const { return a + b; } float operator()(id<2>, int a, float b) const { return a + b; } // ... any<OperationList> operator()(id<100>, any<OperationList> const& a, any<OperationList> const& b) const { // Default case. Use other dispatch mechanisms or throw exception. // ... } }; }; // Other operations // ... typedef any<vector<plus,minus,integral_promotion,/*...*/> > object; -- Alexander Nasonov