develooper Front page | perl.perl6.language.errors | Postings from August 2000

Re: On the case for exception-based error handling.

Thread Previous | Thread Next
From:
Tony Olekshy
Date:
August 23, 2000 21:15
Subject:
Re: On the case for exception-based error handling.
Message ID:
39A4A13C.AA91222D@avrasoft.com
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.  In fact it depends on what they
do now.  To quote from RFC 88:

    Although the following code using the new mechanism:

	try { may_throw_1 }
	catch may_throw_2 => { may_throw_3 }
	finally { may_throw_4 }

    can be written in Perl 5 like this:

	eval { may_throw_1 };
	my $exception = $@;
	if ($exception) {
	    my $test = eval { may_throw_2 };
	    $@ and $exception = $@;
	    if ( ! $@ and $test ) {
		eval { may_throw_3 };
		$exception = $@;
		}
	    }
	eval { may_throw_4 };
	($exception ||= $@) and die $exception;

    the opportunity for flow-control errors increases.

On the other hand, if eval is suddenly supposed to stop catching
so-called non-fatal errors, then all hades breaks loose. Trust me.

Yours, &c, Tony Olekshy

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