Chaim Frenkel <[EMAIL PROTECTED]> writes:
> Why would anyone want to select a different method based upon the
> arguments.
The classic example is event dispatch. Say a generic event
handler knows how to handle an event base class. It dispatches
handling to some class that registered interest in the events.
Somewhere the code has to select the right event handler per
event type. Having "multimethod" support simplifies such code:
It reduces to method declarations. Without it, each registered
class needs to include the code to determine which event
occurred and where its handler is found.
Another example is the exception catching being discussed on
perl6-language-flow. An IO exception contains different data
and is handled differently than a out-of-memory exception.
Without multimethod support, the flow people are arguing
syntax and ways to distinguish among the many exception types
so that the correct handler code is invoked.
Although not as common a need as polymorphism, multimethod
support would be useful.