Conditional catch clause

John J Barton johnjbarton at
Wed Dec 19 17:00:02 PST 2012

On Wed, Dec 19, 2012 at 4:39 PM, Claude Pache <claude.pache at>wrote:

> Throw/catch is useful for exceptions, it doesn't mean that such a
> mechanism could not have other legitimate uses. I think that we are not
> accustomed to use it for anything else than exceptions in everyday code,
> because we don't often need it and we generally find a workaround.

The issue is not lack of imagination. On the contrary, all other uses
interfere with using throw/catch for exceptions.

Debuggers provide break-on-exception as a valuable development feature.
Why? Because developers know that an exception is something the merits
special attention.  If we want to invest in throw/catch we should provide
features like runtime detection of would-be-caught.

> StopIteration is IMHO a nice example of a good use of throwing a
> non-error: The iterator is asked for the next value, but there is none, so
> it throws (but it is not an error), and the execution resume where it
> should (e.g. after a for/of loop or at some place manually identified by a
> catch clause), without the need to add some branching statement at every
> place the iterator is invoked.

I disagree. If this form of iteration is so important, implement it
properly, not as a hack on throw/catch.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list