I fear I'm not adding anything apart from noise to this debate.
(partly from not having thought through the issues completely, partly by
not reading the full archives for the list from last year)
On Mon, Feb 12, 2001 at 01:58:35PM -0700, Tony Olekshy wrote:
> unwind-protect a reality. As a result of all this, there are
> actually people who are thinking that the Perl 6 core should signal
> "errors" via exceptions, so you can just say
>
> my $f = open $file;
>
> instead of:
>
> my $f = open $file or die "can't open $file";
>
> Or as Larry said in his ALS talk, "a completely object-oriented
> exception handling, with a simple string-like interface for those
> who do not want the power of the full OO system." See the notes
> at http://www.avrasoft.com/perl6/rfc88.htm#CONVERSION for more
> information on how this works.
my $f = open $file or die "can't open $file";
is troublesome. It doesn't report *why* the file can't be opened.
Even in perl 5 terms, the "obvious" remedy
open FILE, $file or die "can't open $file: $!";
is troublesome.
1: We (p5p) know of some OSes where opens will fail without setting errno
2: I'm experimenting with PerlIO layers. If a layer decides it can't
honour an open due to a reason not covered by errno, it has no way of
reporting this.
errno is not flexible. *flexible* exceptions are needed
Related
Jarkko would really like
print "Foo\n";
in a void context to behave as
print "Foo\n" or die $!;
I think that it would be nice in 5.8 to (optionally on some pragma?) make
print, close and a few others in void context croak.
It would actually make writing perl scripts easier. You'd know when your
disk became full (or you went over quota), albeit in with a messy error.
OK, script crashing with an uncaught exception isn't nice, but it's nicer
than silently losing data IMHO.
Nicholas Clark