Skip to content

Commit 376253f

Browse files
committed
Document the C<loop> statement
... by shamelessly copying the text from the spec....
1 parent fb6f481 commit 376253f

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/Language/control.pod

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,23 @@ specify a final value for the block.
136136
}
137137
#-> Int
138138
139-
=begin comment
140-
141139
=head2 loop
142140
143-
=end comment
141+
The C<loop> statement is the C-style C<for> loop in disguise:
142+
143+
loop (my $i = 0; $i < 10; $i++) {
144+
...
145+
}
146+
147+
As in C, the parentheses are required if you supply the 3-part spec;
148+
however, the 3-part loop spec may be entirely omitted to write an infinite
149+
loop. That is,
150+
151+
loop {...}
152+
153+
is equivalent to the C-ish idiom:
154+
155+
loop (;;) {...}
144156
145157
=head2 repeat/while, repeat/until
146158

0 commit comments

Comments
 (0)