
On Tue, Dec 19, 2006 at 03:04:38PM -0500, David Abrahams wrote:
Sascha Krissler <boost-dev@k.datenfreihafen.de> writes:
On Mon, Dec 18, 2006 at 04:45:18PM -0500, David Abrahams wrote:
boost library: a generic dispatcher for foreign languages and C++ itself. Right now i am finding out whether one can write an awkward-syntax-predicate- dispatcher in c++.
Huh? What's that?
in the same sense not perfect like boost::lambda is not becuase of the syntactic restrictions of c++. so somewhere in the middle between unusable and without syntactic clutter
I think I'm wondering less about the awkward-syntax than about the "predicate-dispatcher" part.
when you regsiter a candidate method to the multimethod you can optionally pass a function returning bool and the candidate method is only called when the function returns true. This is a generalization of normal multiple dispatch and emulates the latter with: bool fun(argn, ...) { return dynamic_cast<T1>(arg1) && dynamic_cast<T2>(arg2); } the nontrivial part is the ordering of the predicates so that arg1->property1() && arg2->property2() is tested before arg1->property1() because the former is more specific. i was thinking about passing the predicate as a lambda expression and then work on it with a compile time algorithm that operates on the parse tree of the expression template.