develooper Front page | perl.perl5.porters | Postings from July 2013

Re: Try/Catch Exception Objects: Possible?

Thread Previous | Thread Next
From:
David E. Wheeler
Date:
July 25, 2013 10:36
Subject:
Re: Try/Catch Exception Objects: Possible?
Message ID:
58B8ADE3-4450-4E66-BBD0-AD4BD2B94C1A@kineticode.com
On Jul 24, 2013, at 12:05 AM, Aristotle Pagaltzis <pagaltzis@gmx.de> wrote:

> Now I’m not keen on some new ad-hoc type of smartmatch just because it
> would be similar to what other languages offer which already have some
> try/catch construct. So I’d just have `catch` follow the same syntax as
> any other kind of conditional in Perl:
> 
>    my $retry = 0;
>    while ( $retry < 5 ) {
>        try { $some->transaction }
>        catch ( $@->isa('X::Transient') ) { ++$retry }
>    }
> 
> You’d be able to chain multiple `catch`es, of course.

I like it, although I would still like to find a way to avoid the use of a global variable.

Best,

David
Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About