Re: errors and their keywords and where catch can return toandst uff like that

2000-08-15 Thread Graham Barr

On Mon, Aug 14, 2000 at 10:15:21PM -0700, Peter Scott wrote:
 At 08:56 PM 8/14/00 -0600, Tony Olekshy wrote:
 consider this:
 
  try { may_throw_1; }
  catch   { may_throw_2; }
  catch   { may_throw_3; }
  finally { may_throw_4; }
 
 That's either a syntax error or a no-op.  More likely the latter.  If you 
 have multiple catch blocks which could catch the same exception, only the 
 first one should execute.

Yes.

Graham.



Re: errors and their keywords and where catch can return toandst uff like that

2000-08-14 Thread Tony Olekshy

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