Boost logo

Boost :

Subject: Re: [boost] Boost.Multimethod proposal
From: David Bergman (David.Bergman_at_[hidden])
Date: 2009-08-23 13:06:45


On Aug 23, 2009, at 1:34 AM, OvermindDL1 wrote:

> On Sat, Aug 22, 2009 at 10:40 PM, Kim Barrett<kab.conundrums_at_[hidden]
> > wrote:
>> At 11:58 PM -0400 8/22/09, Edward Diener wrote:
>>>
>>> This does not explain the practical purpose of multimethods. I
>>> know what
>>> virtual functions are, of course. What in multimethods improves on
>>> the
>>> polymorphic capabilities of virtual functions that make them a
>>> practical
>>> choice for use over normal polymorphism.
>>
>> The previously referenced paper
>> (http://research.att.com/~bs/multimethods.pdf)
>> contains rationale discussion, including several well chosen
>> examples where
>> multiple dispatch can be beneficial.
>
> To be blunt though, Virtual Methods are not proper OO, multimethods
> are proper OO. C++ has been lacking in this, sometimes important area
> of OO, where things like LISP do wonderfully.

I do not want to start a debate about the fundamentals of OO, but a
short comment will be made: "proper OO" deals with thingies responding
to messages, and different objects (or types of objects) being able to
respond differently on the same message. That is the gist of it. This,
obviously, translates to some form of dispatch based on the thingie's
kind, where most realizations (and concretizations of OO) use
describable classes to decide this 'kind'. I.e., proper OO deals with
uni-dispatch only.

> Hmm, I know LISP has a well optimized multimethod implementation
> written in pure LISP, wonder how easily that method could be
> transferred to C++, although more verbose...

Have you used CLOS?

/David


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk