[Prev][Next][Index][Thread]

Re: Multimethods 101 (was Re: Multiple dispatch (Re: Q: Python 2.0 preliminary features?))



> > You're not suggesting explicit type tests inside foo(A, B) are you?
>
> Aww, *maate*.  Strewth, I'm not suggesting any such thing as a type test.
>
No.  If you know when you are writing the methods that you need to special case
for foo (AA, BB), then you write a method for that variant.  If you don't know,
then the processing of the case depends in a defined way on the cases that you did
define.  If the method executed is foo (A, B), then the processing should not
depend on specializations of A and of B.  If you need to handle the
specializations, then define handlers for them. (e.g. foo (AA, BB) ).

The problem was caused by the hypothesis that no handler existed, and the question
was "Then what should the language do?"  My answer is:  Any of the choices is
valid, so pick one and stick with it.  Of course the best answer is to write the
new handler, but that violates the conditions of the statement of the problem.






References: