Peter Scott wrote:
>
> > try {
> > die "foo";
> > } catch {
> > die "bar";
> > }
> >
> > [...]
>
> Surely the first one catches it cleanly since it has a
> "catch-all" catch clause.
That "catch-all" clause throws. In RFC 88 we said, in the
Definitions section,
Cleanly caught
This means the trapping and handling of an exception did not
itself raise an exception.
So the first one is caught, but it's not cleanly caught.
What's the difference? Consider try { ... } catch { foo() }. If
foo() throws then try's exception isn't cleanly caught, so unwinding
*is* propagated at the end of the try statement. If foo() doesn't
throw the exception is cleanly caught, so unwinding is *not*
propagated at the end of the try statement.
Consider
$r = try { $x / $y } catch { $x / $z };
f();
If $y == 0 you want to use $x / $z for $r and then call f().
But wait, *unless* $z == 0 too, in which case you want to unwind, no?
So, we propagate after an exception if it is not "cleanly" caught.
Just catching it is not enough to terminate propagation, the
catching has itself to be "clean", otherwise there's an exception
in the catch that hasn't been caught. There's a failure in the
failure handling. You want to report that, not catch it. (And if
you do want to catch it, just add clauses.)
Yours, &c, Tony Olekshy