I've moved this from perl6-language to perl6-language-flow.

Graham Barr wrote:
>
>     eval {
>             # fragile code
>     }
>         else {                      # catch ALL exceptions
>         switch ($@) {
>             case __->isa('IO')     { ... }
>             case __->isa('Socket') { ... }
>                 else                   { ... }
>         }
>     }
>         continue {
>            # code always executed (ie finally)
>         }

Chaim Frenkel wrote:
>
> Nice.

Hmm.  The eval was commented to indicate fragile code, which is
implied if the keyword try is used.  The else was commented to
indicate a catch, instead of saying catch, and the continue was
commented to indicate a finally, instead of saying finally.

There does seem to me to be some benefit to the clarity of the
RFC 88 approach, which supports both:

        try { }
        except isa => 'IO'     => catch { }
        except isa => 'Socket' => catch { }
        except else            => catch { }
        finally { }

and:

        try { }
        catch {
            switch ($_[0]) {
                case __->isa('IO')     { ... }
                case __->isa('Socket') { ... }
                else                   { ... }
                }
            }
        finally { }

Yours, &c, Tony Olekshy

Reply via email to