Re: [boost] Re: MultiMethod/Visitor Interest

Hi! I think about multimethods as about generalized version of virtual method. There are compile time virtual methods in C++, and it's ok. Everyone practically use compile time virtual methods. And, by my opinion, the generalized version of them also should be compile time. Maybe we speak about different things? Maybe there should be at least two versions of multimethods: 1) as a generalization of traditional virtual methods; 2) as a generalization of "fully runtime polymorphism".
Which file are you talking about?
I talk about *.h/*.cpp files that aren't located in mm subfolder.

On Sep 29, 2004, at 3:29 AM, Danil Shopyrin wrote:
I think about multimethods as about generalized version of virtual method.
Pretty much.
There are compile time virtual methods in C++, and it's ok. Everyone practically use compile time virtual methods. And, by my opinion, the generalized version of them also should be compile time. Maybe we speak about different things?
Nope, we just have different view points. I see multimethods as complementing virtual members instead of augmenting them. Virtual members are fixed at compile time, efficient, type checked, part of a class, and special case their first argument. Multimethods are dynamic, probably less efficient, largely runtime type checked, not part of a class, and treat all of their arguments equally. The key point is the dynamic bit: one of the weaknesses of C++ is that it's quite static: everything is setup at compile time. This is often fine, but it does limit flexibility. One of the goals in my multimethod library is to add some dynamism to C++ similar to that found in Ruby or Smalltalk.
Maybe there should be at least two versions of multimethods:
1) as a generalization of traditional virtual methods;
2) as a generalization of "fully runtime polymorphism".
Well, what are the advantages to such a scheme? A static library would likely be faster, but an optimized dynamic library should be pretty fast for common usages as well. Can a static library do better type checking? In particular can it figure out, at compile time, if there are no applicable methods or no unambiguous method? -- Jesse

Can a static library do better type checking? In particular can it figure out, at compile time, if there are no applicable methods or no unambiguous method?
That's not meaningful if you want to allow dynamic loading to extend the multi-method family. The dispatch mechanism I used is not as fast as virtual function call for a single "virtual" argument, but it is only a (largish) constant factor off. In a compiler implementation that factor could be reduced fairly close to one as far as I have planned. For more than one "virtual" argument the dispatch cost increases, but not a lot -- it should be linear or close to it for many common usage patterns. Lassi -- People demand freedom of speech to make up for the freedom of thought which they avoid. --Kierkegaard
participants (3)
-
Danil Shopyrin
-
Jesse Jones
-
Lassi A.Tuura