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 23, 2013 19:56
Subject:
Re: Try/Catch Exception Objects: Possible?
Message ID:
36299D95-8FA4-480A-B3D4-DF4732FE20B5@kineticode.com
On Jul 23, 2013, at 9:50 PM, Paul LeoNerd Evans <leonerd@leonerd.org.uk> wrote:

> I'd be quite keen to avoid such things.
> 
> Nowwhere else in Perl do we do this sort of handling of code dispatch
> based on argument types (except for normal dynamic virtual method
> dispatch). One thing I've always liked about Try::Tiny et.al. is that
> they don't get involved in working out how 'catch' dispatch should work.
> 
> We our core 'catch' to have to make such decisions, it suggests a
> slippery slope:
> 
> Do we start adding similar logic in other places? Multimethods?
> 
> Does it just use class names? Can we put custom logic in - where{} clauses?

The catch block should not do conditional execution. One should use a switch statement or whatever inside the catch block.

Might be nice to pass the error, but no other block works that way (only anonymous subs), so using a lexical $_ would probably be the way to go (again, like Try::Tiny).

Just my $0.02.

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