Multiple dispatch again

Anders J. Munch andersjm at inbound.dk
Thu Jan 2 14:58:10 EST 2003


"Samuele Pedroni" <pedronis at bluewin.ch> wrote:
>
> > Suit yourself.  I have no particular need to convince you; I used the
> > example for illustration, not as evidence.
> >
>
> where's inspector in your reformulation?

Oh, you're right, I read the original to hastily, focused on
next-method and missed the role of the inspector subtype completely.
I'm used to argument types being a mostly-redundant mechanism for
catching errors, not a mechanism for specifying execution semantics.

I'll try again: The specs say:
"However, different types of vehicle inspectors may have different
policies."

def inspect(car, inspector):
    for inspection in vehicle.relevant_inspections():
        if inspector.policy_includes(inspection):
            inspection.perform(vehicle)

My, that was hard.  The lack of multimethods forced me add an entire
if-statement ;-)

- Anders







More information about the Python-list mailing list