Skip to content

Commit

Permalink
Finished iterating data structures.
Browse files Browse the repository at this point in the history
It's not perfect, but it's there. Much of it was already covered in
the control flow document. This closes #2069.
  • Loading branch information
JJ committed May 30, 2018
1 parent d00b646 commit 458e6ff
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions doc/Language/iterating.pod6
Expand Up @@ -123,6 +123,22 @@ C<take> and creates a list out of them.
=head1 C<Classic> loops and why we do not like them
Classic C<for> loops, with a loop variable being incremented, can be done in
Perl 6 through the L<C<loop> keyword|/language/control#loop>. Other
L<repeat|/language/control#repeat/while,_repeat/until> and
L<while|/language/control#while,_until> loops are also possible.
However, in general, they are discouraged. Perl 6 is a functional and concurrent
language. In general, you should look at loops in a functional way: processing,
one by one, the items produced by an interator, that is, feeding an item to a
block without any kind of secondary effects. This functional view allows also
easy parallelization of the operation via the L<C<hyper>|/routine/hyper> or
L<C<race>|/routine/race> auto-threading methods.
If you feel more comfortable with your good old loops, the language allows you
to use them. However, it is considered more I<p6y> to try and use, whenever
possible, functional and concurrent iterating constructs.
=end pod

# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

2 comments on commit 458e6ff

@b2gills
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is overuse of the phrase “in general” in this commit.

@JJ
Copy link
Contributor Author

@JJ JJ commented on 458e6ff May 30, 2018 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.