[Python-Dev] type categories
David Abrahams" <email@example.com
Tue, 13 Aug 2002 17:36:55 -0400
From: "Guido van Rossum" <firstname.lastname@example.org>
> Alex Martelli introduced the "Look Before You Leap" (LBYL) syndrome
> for your uneasiness with (4) (and (5), I might add -- I don't know
> that __iter__ is always safe). He contrasts it with a different
> attitude, which might be summarized as "It's easier to ask forgiveness
> than permission." In many cases, there is no reason for LBYL
> syndrome, and it can actually cause subtle bugs.
> While it's not an absolute rule, I tend to dislike interface/protocol
> checking as an example of LBYL syndrome.
> The exception is when you need to do something different based on the
> type of an object and you can't add a method for what you want to do.
> But that is relatively rare.
The main reason I want to be able to LBYL (and, AFAICT, it's the same as
Alex's reason) is to support multiple dispatch. In other words, it wouldn't
be user code doing the looking. The best reason to support protocol
introspection is so that we can provide users with a way to write
more-elegant code, instead of messing around with manual type inspection.
What's your position on multiple dispatch?