Chaim Frenkel wrote:
> 
> See Graham Barr's previous email on this topic.
> 
>         eval {}
>         else {}
>         continue {}
> 
> Very few new keywords, and rather than add something a complex
> mechainism to the catch section, why not use Damian's switch
> internally.  This gives full flexibility to the user with little
> extra overhead.

Here's the deal.  I work with a another one of those groups of
people that are sitting on 100 KLOC of framework and application
code that makes extensive use of eval, die, and $@ functionality.

RFC 88 is our take on the matter, based on Do What I Need ;-)
In our experience, exception handling is sometimes hard, so RFC
88 supports that, but is usually easy, so RFC 88 supports that too.

If Perl doesn't support our needs directly that's certainly ok with
us, as long as we can write modules like Try.pm that do what we need
(that is, implement a more complex mechanism).

That's why RFC 88 points out as long as eval, die, and $@ continue
to work the way they do now (whether or not continue and else
clauses are added to eval), we're certainly happy to leave Try.pm
(and Error.pm) as modules.  The only problem we would have is if we
could no longer implement Try.pm.

It still seems to me though that:

    try {
        try {
            try     { throw "First trouble."; }
            finally { throw "Second trouble."; }
            }
        except First  => catch { throw "First catch."; }
        except Second => catch { throw "Second catch."; }
        except else   => catch { throw "Other catch."; }
        }
    catch { print $_[0]; }

is clearer than this:

    eval {
        eval {
            eval     { throw "First trouble."; }
            continue { throw "Second trouble."; }
            }
        else {
            switch ($@) {
                case /First/  { throw "First catch."; }
                case /Second/ { throw "Second catch."; }
                else          { throw "Other catch."; }
                }
            }
        }
    else { print $@; }

especially if you throw the occasional for/continue and if/else
in there.  Sometimes clarity is important, which is why Perl
allows $x + $y even though, strictly speaking, only subtraction
is needed, as in: $x - (0 - $y), so an extra "keyword" could be
avoided ;-)

RFC 88 only introduces the try, throw, except, catch, finally, and
unwind keywords, which are all traditionally related to exception
handling.  Overloading else and continue with functionality not
traditionally associated with else and continue can be confusing.

Yours, &c, Tony Olekshy

Reply via email to