Re: RFC 63 (v3) Exception handling syntax
[email protected] (Chaim Frenkel) 15 Aug 2000 15:26:11 -0400
| Newsgroups | perl.perl6.language.flow |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "PRL" == Perl6 RFC Librarian <[email protected]> writes: PRL> RFC 80 proposes standard exception classes and methods for core exceptions. PRL> This RFC doesn't need to repeat those, but it can expound upon the PRL> semantics that exception classes ought to have. Assume wlog that they PRL> all inherit from a base class, C<Exception>. Some people think that PRL> exceptions should not be rethrown implicitly. We can provide a boolean flag PRL> in the class or even the exception object itself to be checked for this: PRL> sub Exception::IO::implicit_rethrow { 0 } # One class PRL> sub Exception::implicit_rethrow { 0 } # All classes PRL> throw Exception::Socket(implicit_rethrow => 0); # Just this exception PRL> [Note: it had been proposed that this functionality would be provided by a PRL> method C<uncaught_handler> which would be called if an exception wasn't PRL> caught. PRL> But if that routine decided to rethrow the exception, the C<continue> block PRL> would not get called at the right time.] Please include the comments about global variables and action at a distance. PRL> =head2 Exception classes - ignoring PRL> Note that we could also make it possible to selectively or globally ignore PRL> exceptions, so that perl continues executing the line after the C<throw> PRL> statement. Just import a C<ignore> function that takes a class name: PRL> ignore Exception::IO; # Ignore all I/O exceptions PRL> ignore Exception; # Ignore all exceptions PRL> and when perl sees the C<throw>, it just does nothing. (Or do it by PRL> overriding a base class method as for C<implicit_rethrow> if you don't want PRL> to put another function in the namespace.) Since C<throw> and C<die> PRL> should be essentially identical, this would allow any kind of exception to PRL> be ignored, not just the ones that were C<throw>n. This is not necessarily PRL> a good thing, of course. Oh, no! Are you really suggesting that after open (FOO, "nonesuch") or throw "file not found" The next statement continues?????? How in $DIETY's name do you expect to protect code? PRL> =head2 $SIG{__DIE__} PRL> <$SIG{__DIE__}> needs to be triggered only as a I<last> resort PRL> instead of firing immediately, since it messes with the mind of this and PRL> every other decent exception handling mechanism. Perhaps it should be axed PRL> altogether. Please. $SIG{DIE} should die. Action at a distance. Global. Can't know what other threads or modules want done here. <chaim> -- Chaim Frenkel Nonlinear Knowledge, Inc. [email protected] +1-718-236-0183