At 5:41 PM -0700 9/3/02, David Wheeler wrote:
>On Tuesday, September 3, 2002, at 05:08 PM, Dan Sugalski wrote:
>
>>We call that concept "multimethod dispatch". That's what you're asking for.
>
>Dan, can you explain what "multimethod dispatch" is?
Damian can explain it better than I can, but it's essentially when
you dispatch based on sub or method signature. You're allowed to have
multiple versions of a single sub as long as they differ in their
parameter signature.
So you could have a
sub xyzzy(Foo $a) {
print "Foo!\n";
}
as well as a:
sub xyzzy(Bar $a) {
print "Bar!\n";
}
And at runtime when you call xyzzy, the system looks at your
parameter to decide which to call. Inheritance trees are searched as
well, so if you had a Baz, which ISA Bar, calling xyzzy with a Baz
would print out "Bar!"
Things get... interesting with multiple inheritance, and multiple
parameters, but the general solution to potential conflicts, where
there are two or more equally "right" things is to either use a
default or throw an exception.
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk