Peter Scott wrote:
>
> At 06:48 PM 8/24/00 -0600, Tony Olekshy wrote:
> >
> >I've read 151 a few times, and I don't understand how it can
> >impact the implementation of RFC 88 as a module. Please explain.
>
> If $@ and $! are merged, then in code like
>
> try {
> system_call_that_fails();
> more_stuff_that_succeeds();
> }
> finally {
> }
>
> does the finally block think there is a current exception or not?
> $! was set by the failed system call, but nothing died or threw.
> If $@ is put into $! instead, how does the finally block know that
> it's not an exception? ! ref($!) ...?
I think it is imperative that if Perl has die and eval then it must
have a flag that indicates *only* whether or not eval returned via
normal local flow control or via non-local unwinding started by a
die. Otherwise, I can see no way any quasi-reliable non-local flow
control can be extened by writing blocks of local flow-control code.
So if open, for example, can set $! without invoking die, then $!
and $@ must not be merged. As I read it, 151 would (as currently
promulgated) not meet my requirement for the unique nature of a
$@-style variable. I don't think overloading ref to pick off true
exceptions would make me happy either ;-)
I think that RFC 151 should be *merged* into RFC 80. RFC 80
should define a simple set of lower-case system-reserved fields
to be used for signalling fault information by the Perl 6 core.
RFC 80 should also define a mapping from this simple fault-hash
into a proper Exception object (using, oh, say reference to a
blessed copy of said fault-hash).
Now, hold on to your hat, %@ should the name of this fault-hash...
$@ current exception
@@ current exception stack
%@ current core fault information
$@[0] same as $@
$@{type} "IO::File::NotFound"
$@{message} "can't find file"
$@{param} "/foo/bar/baz.dat"
$@{child} $?
$@{errno} $!
$@{os_err} $^E
$@{chunk} That chunk thingy in some msgs.
$@{file} Source file name of caller.
$@{line} Source line number of caller.
%@ should not contain a severity or fatality classification.
*Every* call to a core API function should clear %@.
Internally, Perl can use a simple structured data type to hold the
whole canonical %@. The code that handles reading from %@ will
construct it out of the internal data on the fly.
If C<use fatal;> is in scope, then just before returning, each core
API function should do something like: %@ and internal_die %@;
The internal_die becomes the one place where a canonical Exception
can be generated to encapsulate %@ just before raising an exception,
whether or not the use of such canonical Exceptions is controlled by
a pragma such as C<use exceptions;>.
Yours, &c, Tony Olekshy