diff options
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2021-02-05 11:58:06 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2021-02-09 00:54:30 +0000 |
commit | 7725f1653b1fa73842ade726f8b8e97630e3d966 (patch) | |
tree | dfd466957970967353e8bd17b46bb656c785d265 /pod/perlsyn.pod | |
parent | 16676e213e35e2dd7ceb8973b640ef7cf43b3ebc (diff) | |
download | perl-7725f1653b1fa73842ade726f8b8e97630e3d966.tar.gz |
Specifically document that return/goto/next/last/redo work as expected inside both try {} and catch {} blocks
Diffstat (limited to 'pod/perlsyn.pod')
-rw-r--r-- | pod/perlsyn.pod | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index 8e3bfbb562..8649d46127 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -613,7 +613,7 @@ Do not rely on it. =head2 Try Catch Exception Handling X<try> X<catch> -The C<try>/C<catch> syntax provides control flow relating to exceptions +The C<try>/C<catch> syntax provides control flow relating to exception handling. The C<try> keyword introduces a block which will be executed when it is encountered, and the C<catch> block provides code to handle any exception that may be thrown by the first. @@ -643,6 +643,13 @@ value that was thrown by the code in the C<try> block. It is not necessary to use the C<my> keyword to declare this variable; this is implied (similar as it is for function signatures). +Both the C<try> and the C<catch> blocks are permitted to contain control-flow +expressions, such as C<return>, C<goto>, or C<next>/C<last>/C<redo>. In all +cases they behave as expected without warnings. In particular, a C<return> +expression inside the C<try> block will make its entire containing function +return - this is in contrast to its behaviour inside an C<eval> block, where +it would only make that block return. + This syntax is currently experimental and must be enabled with C<use feature 'try'>. It emits a warning in the C<experimental::try> category. |