Who needs exceptions (was Re: Two languages, too similar, competing in the same space.)

François Pinard pinard at iro.umontreal.ca
Wed Jan 2 15:11:55 CET 2002


[Ville Vainio]

> One great thing about exceptions as opposed to retval-checking is that
> when you are making the initial version, you don't have to implement
> error-checking at all!

This is great, indeed.

Besides, it is extremely heavy to correctly error-check all calls to
library functions.  I remember having worked in some C code in which the
original programmer tested the return value of each and every `printf',
with appropriate error reporting.  This yielded code which is noisy,
hard to read, and irritating to maintain.

My feeling is that C programmers (and I still work at C programs once in a
while :-) do a "reasonable" error checking, but are rarely fully thorough
with it.  A compromise is needed, because both extremes (no error checking
at all, checking every possible error) are just unbearable in real programs.

I'm very convinced that Python has a fruitful approach on this.  All errors
are handled in some way, and the user always have control for errors to
be reported with nicer diagnostics, or handled more gracefully, at the
price of writing only a few lines then.  That's very bearable, and better.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list