perl6-language
[Top] [All Lists]

Re: Catching exceptions with the // operator

To: perl6-language@perl.org
Subject: Re: Catching exceptions with the // operator
From: TSa <Thomas.Sandlass@barco.com>
Date: Fri, 08 Aug 2008 18:19:40 +0200
Delivered-to: mailing list perl6-all@perl.org
Delivered-to: perl6-all-poster@perl.org
Delivered-to: mailing list perl6-language@perl.org
Delivered-to: perl6-language@perl.org
In-reply-to: <489C0D2C.7080407@yaakovnet.net>
List-help: <mailto:perl6-all-help@perl.org>
List-id: <perl6-all.perl.org>
List-id: <perl6-language.perl.org>
List-post: <mailto:perl6-all@perl.org>
List-subscribe: <mailto:perl6-all-subscribe@perl.org>
List-unsubscribe: <mailto:perl6-all-unsubscribe@perl.org>
Mailing-list: contact perl6-all-help@perl.org; run by ezmlm
References: <1218038332.v2.mailanyonewebmail-274283@fuse114> <1d9a3f400808060936x3bad8100x24ee854a268a63de@mail.gmail.com> <20080806170828.GA10616@wall.org> <489C0D2C.7080407@yaakovnet.net>
HaloO,

Yaakov Belch wrote:
I believe that ---from a usability point of view--- it's very important to:

* classify exceptions by "severity" or other characteristics,
* provide named adverbs/pragmas to modify default CATCH handlers,
* make them configurable by "outer scopes".
> [..]
The programmer of the top-level function defines the severity of
particular exception groups for this specific application by defining named
CATCH handlers.

I want to propose---possibly again ;)---to use the dispatch
semantics for this purpose. The idea is that CATCH blocks
can be made into multis first of all with the multi keyword
or with a proto which then makes inner CATCH blocks also multi
unless they are explicitly declared only.

Generally speaking I find multiple CATCH blocks with a signature
better than a big switch inside a single one. Such a CATCH without
signature would be good for low-level handling, though. It has
implicit signature :(Any) and is easily overridden from outer
scopes.

The grouping comes naturally since packages are recognized as
type names. So we can have

  proto CATCH {...} # force multi
  {
     multi CATCH (Math::DivZero) {...}
     {
        multi CATCH (Math) {...}
        multi CATCH (Math::Overflow) {...} # more specific
        # outer catch seen here as well
        {
           CATCH
           {
              when Math {...} # never called
           }
        }
     }
  }

And if we really go so far, we can have standard names for two
CATCH handlers:  "CATCH://" and "CATCH:orelse".

So with CATCH a magic namespace these would be CATCH::<//> and
CATCH::<orelse> respectively. Using the namespace is another
approach. But to me it doesn't feel as natural as the exception
type approach.


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan


<Prev in Thread] Current Thread [Next in Thread>