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

Re: Try/Catch Exception Objects: Possible?

Thread Previous | Thread Next
Paul "LeoNerd" Evans
July 23, 2013 19:55
Re: Try/Catch Exception Objects: Possible?
Message ID:
On Mon, 22 Jul 2013 23:44:42 +0200
"David E. Wheeler" <> 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
ICQ# 4135350       |  Registered Linux# 179460

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About