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

Re: Try/Catch Exception Objects: Possible?

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
July 23, 2013 19:55
Subject:
Re: Try/Catch Exception Objects: Possible?
Message ID:
20130723205450.5dd2bc90@shy.leonerd.org.uk
On Mon, 22 Jul 2013 23:44:42 +0200
"David E. Wheeler" <david@justatheory.com> wrote:

> * the new syntax would be no big deal, thanks to `feature`.
> * Changing `die` to create exception objects would be straight-forward
> * Changing core errors to category-specific exceptions would mostly be
>   busy work, though maybe it can be derived from autodie

Here's an amusing question: In such a scheme, would we still want 'die'
to be the exception-throwing keyword? Why not 'throw'?

This might help avoid some tricky questions about how 'die' works in
such a context.

 try {
   throw Thingy;
 }
 catch {
   # caught Thingy here, in $_ or $@ or somewhere...
 }

Now we'd just have to consider how legacy die()-using code can be
supported in try/throw/catch. Perhaps the exception type it catches is
DieException, or some less Javaine name.

And now how throw()-using code behaves outside of a try{} block. Since
eval{} is only expecting stringy-like things anyway, that's the time to
stringify it.

die-in-eval can remain unchanged.

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/

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