Peter Scott wrote:
If anyone suggests that
try { }
catch Exception::Foo, Exception::Bar { ... }
catch { exception thrown here causes it to
start going through catch blocks again }
then I'm afraid I'm going to have to turn to drink.
Agreed. However, consider this:
try { may_throw_1; }
catch { may_throw_2; }
catch { may_throw_3; }
finally { may_throw_4; }
Under what conditions should the second catch clause be invoked?
Under what conditions should the above unwind after finally (vs
continuing the normal order of execution? RFC 88 currently goes
into the second catch if the first catch throws, but perhaps it
should go straight to the finally if any catch throws.
Or maybe not. Consider this case (in pseudo-syntax):
my $o = SomeClass-New;
try { f ($o); }
catch $@-ImpliesFooCleanup { $o-AttemptFooCleanup; }
catch $@-ImpliesBarCleanup { $o-AttemptBarCleanup; }
finally { $o-Done; }
If you would want to attempt bar cleanup even if attempting
foo cleanup fails (throws), then RFC 88 gets it right (the
syntax is different, and the unwind stack is used to prevent
the second exception from hiding the first one, but it works).
We either have to disallow multiple and conditional catches
and move everything to a catch-all block and do all the
flow control manually (for which we already have eval {}),
or we have to specify the semantics for multiple conditional
catches.
Yours, c, Tony Olekshy