Skip to content

Commit 45b3c3c

Browse files
committed
Mention phasers a bit more explicitly in the Control page
1 parent 5c78c26 commit 45b3c3c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

doc/Language/control.pod6

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ You have to watch out for this in most languages anyway to prevent things
8585
from getting accidentally commented out. Many of the examples below may
8686
have unnecessary semicolons for clarity.
8787
88+
=head1 X<Phasers|control flow,Phasers>
89+
90+
Blocks may have phasers: special labeled blocks that break their execution
91+
into phases that run in particular phases. See the page
92+
L<phasers|/language/phasers> for the details.
93+
8894
=head1 X<do|control flow,do>
8995
9096
The simplest way to run a block where it cannot be a stand-alone statement
@@ -912,6 +918,24 @@ for @x -> $x {
912918
913919
prints "1245".
914920
921+
If the C<NEXT> L<phaser|/language/phasers> is present, it runs before the next iteration:
922+
923+
=begin code
924+
my Int $i = 0;
925+
while ($i < 10) {
926+
if ($i % 2 == 0) {
927+
next;
928+
}
929+
930+
say "$i is odd.";
931+
932+
NEXT {
933+
$i++;
934+
}
935+
}
936+
# OUTPUT: «1 is odd.␤3 is odd.␤5 is odd.␤7 is odd.␤9 is odd.␤»
937+
=end code
938+
915939
=head1 X<last|control flow, last>
916940
917941
The C<last> command immediately exits the loop in question.
@@ -927,6 +951,25 @@ for @x -> $x {
927951
928952
prints "12".
929953
954+
If the C<LAST> L<phaser|/language/phasers> is present, it runs:
955+
956+
=begin code
957+
my Int $i = 1;
958+
while ($i < 10) {
959+
if ($i % 5 == 0) {
960+
last;
961+
}
962+
963+
LAST {
964+
say "The last number was $i.";
965+
}
966+
NEXT {
967+
$i++;
968+
}
969+
}
970+
# OUTPUT: «The last number was 5.␤»
971+
=end code
972+
930973
=head1 X<redo|control flow, redo>
931974
932975
The C<redo> command restarts the loop block without evaluating the

0 commit comments

Comments
 (0)