[Python-Dev] type categories

David Abrahams dave@boost-consulting.com
Sat, 17 Aug 2002 15:43:13 -0400


From: "Andrew Koenig" <ark@research.att.com>


> David> It's pretty hard to see how you could construe my remarks as
> David> asserting some interpretation of what you were saying.
>
> It sure looked that way to me.

Maybe you were just reading fast and confused yourself with Mr. Alex
Martelli?
(http://aspn.activestate.com/ASPN/Mail/Message/1320579)

> In any event, I can think of other contexts in which LBYL can be
> useful.

Of course; I never meant to imply that multiple dispatch was the only
reason to LBYL; it just happens to be the most important one to me.

> To go back to Guido's example, I agree completely that
> testing whether a file exists, and then opening it in a separate
> operation, is a bad idea.  One reason is that by the time you get
> around to opening the file, it may no longer exist, so the open
> has to test anyway.
>
> On the other hand, it does make sense to test whether what you have is
> a valid file name as soon as you know that you are going to open the
> file, even if you aren't going to open it for a while.  The principle
> here is that when failure is certain, failing early is usually better
> than failing late.

Usually this goes to the same question we were discussing about
re-iterability detection. You want to fail early because it's faster, but
also because you don't want to mutate important program state in some
un-recoverable way in systems that are actually supposed to recover from
errors.

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave@boost-consulting.com * http://www.boost-consulting.com