Skip to content

Commit 193ade9

Browse files
committed
Adding a reference to use fatal refs #1274
1 parent f67de57 commit 193ade9

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

doc/Language/exceptions.pod6

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ Output:
157157
=end code
158158
159159
A C<try>-block is a normal block and as such treats its last statement as the
160-
return value of itself. We can therefore use it as a right-hand side.
160+
return value of itself. As a block, it will have by default turned on the
161+
L<C<use fatal> pragma|/language/pragmas#index-entry-fatal-fatal>. We can
162+
therefore use it as a right-hand side.
161163
162-
=begin code
163-
say try { +"99999" } // "oh no";
164-
say try { +"hello" } // "oh no";
165-
166-
# OUTPUT: «99999␤oh no␤»
167-
=end code
164+
=begin code
165+
say try { +"99999" } // "oh no"; # OUTPUT: «99999␤»
166+
say try { +"hello" } // "oh no"; # OUTPUT: «oh no␤»
167+
=end code
168168
169169
Try blocks support C<else> blocks indirectly by returning the return value of
170170
the expression or L<Nil|/type/Nil> if an exception was thrown.

doc/Language/pragmas.pod6

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
In Perl 6, B<pragmas> are core modules used to either identify a
88
specific version of Perl 6 to be used or to modify its normal behavior
9-
in some way. They are "use"ed in your code just as normal modules:
9+
in some way. They are C<use>d in your code just as normal modules:
1010
1111
=begin code
1212
use v6.c;
@@ -41,9 +41,9 @@ block below reaches the C<say $x.^name;> line and prints C<Failure> in output.
4141
4242
In the second block, the C<use fatal> pragma is enabled, so the C<say> line is
4343
never reached because the L<Exception> contained in the L<Failure> returned from
44-
prefix C<+> gets thrown and the C<CATCH> block gets run, printing the C<Caught...>
45-
line. Note that both blocks are the same program and C<use fatal> only affects
46-
the lexical block it was used in:
44+
prefix C<+> gets thrown and the C<CATCH> block gets run, printing the
45+
C<Caught...> line. Note that both blocks are the same program and C<use fatal>
46+
only affects the lexical block it was used in:
4747
4848
{
4949
my $x = +"a";
@@ -58,8 +58,9 @@ the lexical block it was used in:
5858
CATCH { default { say "Caught {.^name}" } }
5959
} # OUTPUT: «Caught X::Str::Numeric␤»
6060
61-
Inside of a L«C<try> blocks|/language/exceptions#index-entry-try_blocks-try», the
62-
C<fatal> pragma is enabled by default, and you can I<disable> it with C<no fatal>:
61+
Inside L«C<try> blocks|/language/exceptions#index-entry-try_blocks-try», the
62+
C<fatal> pragma is enabled by default, and you can I<disable> it with C<no
63+
fatal>:
6364
6465
try {
6566
my $x = +"a";

0 commit comments

Comments
 (0)