Luke ~

These matters are covered at some length in RFC 88 and Apocalypse 4.

    http://www.avrasoft.com/perl6/rfc88.htm

    http://www.perl.com/pub/a/2002/01/15/apo4.html

Yours, &c, Tony Olekshy

Luke Palmer wrote, at 2003-11-23 11:55:
> 
> I was reading over some code that used the MIDI module, and saw the
> C<write_to_file> method.  I began wondering, how does one report the
> error if he feels like it, but let the module report the error if not,
> in a concise way.
> 
> What about something along the lines of a C<catch> statement modifier,
> like:
> 
>     $opus.write_to_file($file) catch die "Couldn't write to $file: $!\n";
> 
> Which would be equivalent to:
> 
>     try {
>         $opus.write_to_file($file);
>         CATCH {
>             die "Couldn't write to $file: $!"
>         }
>     }
> 
> It doesn't read quite as nicely as I'd like, but I think it could be a
> very useful notation.  After all, if I have to type a lot when I'm
> handling errors, I'll prefer not to handle them at all.
> 
> Which reminds me, if you throw an exception inside a CATCH block, does
> it propogate outside to be caught by other CATCHes in the same block
> that are lexically lower, or does it propogate outside of the enclosing
> scope.  That might be a little confusing... for example:
> 
>     try {
>         try {
>             do_something();  # Throws
>             CATCH { die "Foo" }
>             CATCH { die "Bar" }
>         }
>         CATCH { print "$!" }
>     }
> 
> Does that print Foo or Bar?
> 
> Luke
> 
> 


Reply via email to