Jonathan Scott Duff wrote:
> 
> On Mon, Aug 14, 2000 at 04:09:41AM -0600, Tony Olekshy wrote:
> >
> > $@->CanFoo is an example of semantics that determines whether or
> > not the exception is caught; stringification may be an example
> > of semantics that comes into play when an exception is caught.
> 
> Ah, this is why I started asking I guess.  Some people were proposing
> a try/catch like the following:
> 
>         try { }
>         catch SomeException { }
>         catch SomeOtherException { }
>         finally { }
> 
> which seems to only catch exceptions based on name.  Which implies to
> me that, for exceptions to have useful semantics, they'd have to be
> rethrown after they're caught.  I like the following, but it would
> also seem that exceptions that aren't handled here would have to be
> rethrown so that an upstream catch could handle them.
> 
>         try { }
>         catch {                         # ALL exceptions
>             switch ($@) {
>                 case ^_->name eq 'IO'   { ... }
>                 case ^_->canFoo         { ... }
>                 throw $@;               # No cases matched, rethrow
>             }
>         }
>         finally { }

This is why RFC 88 is working on syntax and semantics for:

    try { ... } except sub { $_[0]->CanFoo } => catch { ... }

which *does* unwind if $_[0] can't Foo (or, if $_[0]->CanFoo or the
catch clause throws).

Yours, &c, Tony Olekshy

Reply via email to