develooper Front page | perl.perl6.language | Postings from October 2002

Re: Indeterminate math

From:
Michael G Schwern
Date:
October 15, 2002 13:09
Subject:
Re: Indeterminate math
Message ID:
20021015200859.GG29682@ool-18b93024.dyn.optonline.net
On Tue, Oct 15, 2002 at 01:44:50PM -0500, Jonathan Scott Duff wrote:
> People have used the terms "error" and "exception" interchangably in
> this disucssion.  To me, an "error" is something that stops program
> execution while an "exception" may or may not stop execution depending
> on what the user decides to do about exceptions.

Unless I've missed my mark, Perl errors have always been trappable [1].  Does
that make them exceptions?  We've been calling them errors for years now.

Put another way, is there a significant difference between:

    eval {
    	$foo = 1/0;
	print "Bar";
    }
    if( $@ =~ /^Illegal division by zero/ ) {
    	... oops ...
    }

and

    try {
        $foo = 1/0;
	print "Bar";
    }
    catch {
        when /^Illegal division by zero/ {
	    ... oops ...
	}
    }

(putting aside that exception handlers stack).

Whatever you call it, exception or error, it will halt the program if left
unhandled.


[1] Less the few odd really hard core "the interpreter is having a bad trip"
sort of errors.


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <perl-qa@perl.org>         Kwalitee Is Job One
Here's hoping you don't harbor a death wish!



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About