
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