Author: benmorrow Date: 2009-08-16 21:16:39 +0200 (Sun, 16 Aug 2009) New Revision: 28005
Modified: docs/Perl6/Spec/S04-control.pod Log: [Spec] Clarify behaviour of closure traits when an exception is thrown. Modified: docs/Perl6/Spec/S04-control.pod =================================================================== --- docs/Perl6/Spec/S04-control.pod 2009-08-16 04:04:31 UTC (rev 28004) +++ docs/Perl6/Spec/S04-control.pod 2009-08-16 19:16:39 UTC (rev 28005) @@ -1232,6 +1232,21 @@ before C<BEGIN>, C<CHECK>, or C<INIT>, since those are done at compile or process initialization time). +If an exception is thrown through a block without a C<CATCH> block, the +C<LEAVE>, C<UNDO> and C<POST> blocks will be run at that point, with +C<$!> set to the in-flight exception. If there is no in-flight +exception when these blocks are run, C<$!> will be C<undef>. The last +exception caught in the outer block is available as C<< OUTER::<$!> >>, +as usual. + +An exception thrown from an C<ENTER> block will abort the C<ENTER> +queue, but one thrown from a C<LEAVE> block will not. The exceptions +thrown by failing C<PRE> and C<POST> blocks cannot be caught by a +C<CATCH> in the same block, which implies that C<POST> blocks are not +run if a C<PRE> block fails. If a C<POST> fails while an exception is in +flight the C<POST> failure doesn't replace C<$!> but goes straight into +C<$!.pending>. + For blocks such as C<KEEP> and C<POST> that are run when exiting a scope normally, the return value (if any) from that scope is available as the current topic. (It is presented as a C<Capture> object.)