Author: lwall Date: 2010-07-12 21:52:08 +0200 (Mon, 12 Jul 2010) New Revision: 31645
Modified: docs/Perl6/Spec/S04-control.pod Log: [S04] try to nail down CATCH exit semantics a bit more water-tightly Modified: docs/Perl6/Spec/S04-control.pod =================================================================== --- docs/Perl6/Spec/S04-control.pod 2010-07-12 17:51:44 UTC (rev 31644) +++ docs/Perl6/Spec/S04-control.pod 2010-07-12 19:52:08 UTC (rev 31645) @@ -13,8 +13,8 @@ Created: 19 Aug 2004 - Last Modified: 9 Jul 2010 - Version: 100 + Last Modified: 12 Jul 2010 + Version: 101 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -986,6 +986,25 @@ it treats code inside a C<default> block differently from code that's after all the C<when> blocks but not in a C<default> block. +More specifically, when you write: + + CATCH { + when Mumble {...} + default {...} + } + +you're really getting something more like: + + CATCH { + when Mumble {...} + default {...} + + leave(Failure); + + KEEP (die("Pending exceptions not handled in $!") unless all($!.pendingĀ».handled); $!.handled = 1); + UNDO die $!; + } + A C<CATCH> block sees the lexical scope in which it was defined, but its caller is the dynamic location that threw the exception. That is, the stack is not unwound until some exception handler chooses to