Skip to content

Commit c624b1c

Browse files
committed
Reformatting and reflow
1 parent d7a2a42 commit c624b1c

File tree

1 file changed

+59
-53
lines changed

1 file changed

+59
-53
lines changed

doc/Language/list.pod6

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
55
=SUBTITLE Positional data constructs
66
7-
Lists have been a central part of computing since before there were computers,
8-
during which time many devils have taken up residence in their details. They
9-
were actually one of the hardest parts of Perl 6 to design, but through
10-
persistence and patience, Perl 6 has arrived with an elegant system for handling
11-
them.
7+
Lists have been a central part of computing since before there were
8+
computers, during which time many devils have taken up residence in
9+
their details. They were actually one of the hardest parts of Perl 6 to
10+
design, but through persistence and patience, Perl 6 has arrived with an
11+
elegant system for handling them.
1212
1313
=head1 Literal lists
1414
@@ -219,16 +219,17 @@ to an C<@>-sigiled variable.
219219
@s[1]; # does not say anything
220220
@s[4]; # says 42 two more times
221221
222-
You may also use the C<.cache> method instead of C<.list>, depending
223-
on how you want the references handled. See the L<page on C<Seq>|/type/Seq>
224-
for details.
222+
You may also use the C<.cache> method instead of C<.list>, depending on
223+
how you want the references handled. See the L<page on
224+
C<Seq>|/type/Seq> for details.
225225
226226
=comment TODO document .iterator
227227
228228
=head2 Slips
229229
230230
Sometimes you want to insert the elements of a list into another list.
231-
This can be done with a special type of list called a L<Slip|/type/Slip>.
231+
This can be done with a special type of list called a
232+
L<Slip|/type/Slip>.
232233
233234
say (1, (2, 3), 4) eqv (1, 2, 3, 4); # OUTPUT: «False␤»
234235
say (1, Slip.new(2, 3), 4) eqv (1, 2, 3, 4); # OUTPUT: «True␤»
@@ -329,11 +330,12 @@ to put an infinite list, lest your program hang and, eventually, run out of memo
329330
my @a = (loop { $i.say; last unless --$i }); # OUTPUT: «3␤2␤1␤»
330331
say "take off!";
331332
332-
=head2 Flattening "Context"
333+
=head2 Flattening "context"
333334
334-
When you have a list that contains sub-lists, but you only want one flat list,
335-
you may flatten the list to produce a sequence of values as if all parentheses
336-
were removed. This works no matter how many levels deep the parentheses are nested.
335+
When you have a list that contains sub-lists, but you only want one flat
336+
list, you may flatten the list to produce a sequence of values as if all
337+
parentheses were removed. This works no matter how many levels deep the
338+
parentheses are nested.
337339
338340
say (1, (2, (3, 4)), 5).flat eqv (1, 2, 3, 4, 5) # OUTPUT: «True␤»
339341
@@ -356,15 +358,16 @@ flattening:
356358
357359
When a list appears as arguments to a function or method call, special
358360
syntax rules are at play: the list is immediately converted into a
359-
C<Capture>. A C<Capture> itself has a List (C<.list>) and a Hash (C<.hash>).
360-
Any C<Pair> literals whose keys are not quoted, or which are not parenthesized,
361-
never make it into C<.list>. Instead, they are considered to be named
362-
arguments and squashed into C<.hash>. See the L<page on C<Capture>|/type/Capture>
363-
for the details of this processing.
361+
C<Capture>. A C<Capture> itself has a List (C<.list>) and a Hash
362+
(C<.hash>). Any C<Pair> literals whose keys are not quoted, or which are
363+
not parenthesized, never make it into C<.list>. Instead, they are
364+
considered to be named arguments and squashed into C<.hash>. See the
365+
L<page on C<Capture>|/type/Capture> for the details of this processing.
364366
365-
Consider the following ways to make a new C<Array> from a C<List>. These ways
366-
place the C<List> in an argument list context and because of that, the C<Array>
367-
only contains C<1> and C<2> but not the C<Pair> C<:c(3)>, which is ignored.
367+
Consider the following ways to make a new C<Array> from a C<List>.
368+
These ways place the C<List> in an argument list context and because of
369+
that, the C<Array> only contains C<1> and C<2> but not the C<Pair>
370+
C<:c(3)>, which is ignored.
368371
369372
Array.new(1, 2, :c(3));
370373
Array.new: 1, 2, :c(3);
@@ -615,33 +618,34 @@ by hand to undo the nesting:
615618
616619
say gather [0, [(1, 2), [3, 4]], $(5, 6)].deepmap: *.take; # OUTPUT: «(1 2 3 4 5 6)␤»
617620
618-
...future versions of Perl 6 might find a way to make this easier. However,
619-
not returning Arrays or itemized lists from functions, when non-itemized lists
620-
are sufficient, is something that one should consider as a courtesy to their
621-
users:
621+
... Future versions of Perl 6 might find a way to make this easier.
622+
However, not returning Arrays or itemized lists from functions, when
623+
non-itemized lists are sufficient, is something that one should consider
624+
as a courtesy to their users:
622625
623-
=item use Slips when you want to always merge with surrounding lists
624-
=item use non-itemized lists when you want to make it easy for the user to flatten
625-
=item use itemized lists to protect things the user probably will not want flattened
626-
=item use Arrays as non-itemized lists of itemized lists, if appropriate,
627-
=item use Arrays if the user is going to want to mutate the result without copying it first.
626+
=item Use C<Slip>s when you want to always merge with surrounding lists.
627+
=item Use non-itemized lists when you want to make it easy for the user to flatten.
628+
=item Use itemized lists to protect things the user probably will not want flattened.
629+
=item Use C<Arrays> as non-itemized lists of itemized lists, if appropriate.
630+
=item Use C<Array>s if the user is going to want to mutate the result without copying it first.
628631
629-
The fact that all elements of an array are itemized (in C<Scalar> containers)
630-
is more a gentleman's agreement than a universally enforced rule, and it is
631-
less well enforced that typechecks in typed arrays. See the section below
632-
on binding to Array slots.
632+
The fact that all elements of an array are itemized (in C<Scalar>
633+
containers) is more a gentleman's agreement than a universally enforced
634+
rule, and it is less well enforced that typechecks in typed arrays. See
635+
the section below on binding to Array slots.
633636
634637
=head2 Literal arrays
635638
636-
Literal Arrays are constructed with a List inside square brackets. The List is
637-
eagerly iterated (at compile time if possible) and values in the list are each
638-
type-checked and itemized. The square brackets themselves will spill elements
639-
into surrounding lists when flattened, but the elements themselves will not
640-
spill due to the itemization.
639+
Literal C<Array>s are constructed with a C<List> inside square brackets.
640+
The C<List> is eagerly iterated (at compile time if possible) and values
641+
in it are each type-checked and itemized. The square brackets
642+
themselves will spill elements into surrounding lists when flattened,
643+
but the elements themselves will not spill due to the itemization.
641644
642645
=head2 Mutability
643646
644-
Unlike lists, Arrays are mutable. Elements may deleted, added, or changed.
647+
Unlike lists, C<Array>s are mutable. Elements may deleted, added, or
648+
changed.
645649
646650
my @a = "a", "b", "c";
647651
@a.say; # OUTPUT: «[a b c]␤»
@@ -655,22 +659,23 @@ Unlike lists, Arrays are mutable. Elements may deleted, added, or changed.
655659
656660
=head3 Assigning
657661
658-
Assignment of a list to an Array is eager. The list will be entirely evaluated,
659-
and should not be infinite or the program may hang. Assignment to a slice of
660-
an C<Array> is, likewise, eager, but only up to the requested number of elements,
661-
which may be finite:
662+
Assignment of a list to an C<Array> is eager. The list will be entirely
663+
evaluated, and should not be infinite or the program may hang.
664+
Assignment to a slice of an C<Array> is, likewise, eager, but only up to
665+
the requested number of elements, which may be finite:
662666
663667
my @a;
664668
@a[0, 1, 2] = (loop { 42 });
665669
@a.say; # OUTPUT: «[42 42 42]␤»
666670
667-
During assignment, each value will be typechecked to ensure it is a permitted
668-
type for the C<Array>. Any C<Scalar> will be stripped from each value and a
669-
new C<Scalar> will be wrapped around it.
671+
During assignment, each value will be typechecked to ensure it is a
672+
permitted type for the C<Array>. Any C<Scalar> will be stripped from
673+
each value and a new C<Scalar> will be wrapped around it.
670674
671675
=head3 Binding
672676
673-
Individual Array slots may be bound the same way C<$>-sigiled variables are:
677+
Individual Array slots may be bound the same way C<$>-sigiled variables
678+
are:
674679
675680
my $b = "foo";
676681
my @a = 1, 2, 3;
@@ -679,11 +684,12 @@ Individual Array slots may be bound the same way C<$>-sigiled variables are:
679684
$b = "bar";
680685
@a.say; # OUTPUT: «[1 2 "bar"]␤»
681686
682-
...but binding Array slots directly to values is strongly discouraged. If you do,
683-
expect surprises with built-in functions. The only time this would be done is if
684-
a mutable container that knows the difference between values and Scalar-wrapped
685-
values is needed, or for very large Arrays where a native-typed array cannot be used.
686-
Such a creature should never be passed back to unsuspecting users.
687+
... But binding C<Array> slots directly to values is strongly
688+
discouraged. If you do, expect surprises with built-in functions. The
689+
only time this would be done is if a mutable container that knows the
690+
difference between values and Scalar-wrapped values is needed, or for
691+
very large C<Array>s where a native-typed array cannot be used. Such a
692+
creature should never be passed back to unsuspecting users.
687693
688694
=end pod
689695

0 commit comments

Comments
 (0)