Tony Olekshy wrote:
> Chaim Frenkel wrote:
> >
> > Tony Olekshy wrote:
> >
> > > If no exception is in scope Perl should continue to generate and
> > > propagate exceptions (die and $@) as it does now, so we don't
> > > break tradition.
> >
> > No, that should be the difference between die and throw. Die is
> > immediately fatal. (i.e. current semantics) throw is new and does
> > the magic.
> >
> > We get no breakage that way.
>
> But if die and eval are supposed to do keep doing what they do now,
> RFC 88 doesn't impact them at all.
Here's some code that returns one non-fatal error. I'd like to change
it to use the new RFC 88 mechanism. Please show me how. I've included
how to do it via RFC 119. Note that sub really_delicate_code is
documented that only one possible non-fatal error can occur, although a
variety of fatal errors are possible, hence by the time ... error
handling code ... is invoked, it can assume that is the error that
occurred.
sub really_delicate_code {
my ( $o, $my ) = @_;
die "excessive flibbertygibbets" if $o > $my;
die "insufficient flibbertygibbets" if $o < 43;
die "you're out of your mind" if $my > $mind; # $mind is global, I
guess
return "$my > 100" if $my > 100; # here's the non-fatal error
return $o + $my;
}
$foo = 300;
$bar = 300;
$result = & really_delicate_code ( $foo, $bar );
if ( $result eq "$bar > 100" ) { ... error handling code here ... };
with RFC 199, the conversion is simple:
sub really_delicate_code {
my ( $o, $my ) = @_;
die "$o > 100" if $o > 100;
die "insufficient flibbertygibbets" if $o < 43;
die "you're out of your mind" if $my > $mind; # $mind is global, I
guess
throw "$my > 100" if $my > 100; # here's the non-fatal error
return $o + $my;
}
$foo = 300;
$bar = 300;
{ $result = & really_delicate_code ( $foo, $bar );
catch { ... error handling code here ... };
}
--
Glenn
=====
There are two kinds of people, those
who finish what they start, and so
on... -- Robert Byrne
_____NetZero Free Internet Access and Email______
http://www.netzero.net/download/index.html