From: David Abrahams (dave_at_[hidden])
Date: 2004-09-18 06:15:10
Jesse Jones <jesjones_at_[hidden]> writes:
> I've been working on a multimethod library for C++ and, in my opinion,
> it's turned out rather well. It's modeled closely after the
> multimethods in CLOS and Dylan so it's more flexible than the other
> (pure C++) multimethod libraries I have seen. In particular, new
> methods can be added at runtime, polymorphic dispatch doesn't require
> exact matches, and methods can call the next most specific method
> (sort of how a virtual member can call the inherited member).
> The nicest feature of multimethods is that they allow classes to be
> extended with virtual members without editing the classes. It's
> completely transparent: the class doesn't need to be coded to allow
> for multimethods and new multimethods can be added without touching
> any existing code. It's a far nicer model than using the Visitor
> The other advantage is that it makes multiple dispatch trivial. This
> is useful for things like intersection tests, drag and drop, event +
> view message handling, etc. Without multiple dispatch these sorts of
> things are rather painful to write and normally require a lot of
> switching on types.
> The design is quite simple: there's a generic function object to which
> you dynamically add compatible function objects (using operator<<), an
> operator() that is invoked which will then call the most specialized
> function object (or method) that applies to the actual arguments, and
> a next_method member that can be used within a method to call the next
> most specialized method.
> The source can be found at
> <http://sourceforge.net/projects/multimethods/>. Currently it works
> with CodeWarrior 9.2. There are a bunch of test files, but no examples
> or docs as of yet.
> So, does this sound like something boost would be interested in?
How does this stack up against http://tinyurl.com/5qxky?
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk