Skip to content

Commit 0812f14

Browse files
authored
more precise wording re. slurpies (#4686)
1 parent 53aadf4 commit 0812f14

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

doc/Language/signatures.rakudoc

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ It can have any name; conventionally, it's an underscore:
106106

107107
Signatures can also contain a slurpy positional parameter
108108
(which must be the last of all positional parameters);
109-
it slurps up any extra positional arguments into one big array.
109+
it slurps up any extra positional arguments into one big L<C<Array>|/type/Array>.
110110
The slurpy positional parameter can be one of L<three kinds|/language/signatures#Types_of_slurpy_array_parameters>:
111111

112-
my $sig = :($p, :$n, **@_); # keep arguments the way they are
113-
my $sig = :($p, :$n, *@_); # flatten any iterable arguments
114-
my $sig = :($p, :$n, +@_); # flatten the argument if it is _one_ iterable, else act like **@_
112+
my $sig = :($p, :$n, **@_); # keep arguments as they are: @_ contains one entry per argument
113+
my $sig = :($p, :$n, *@_); # flatten any lists
114+
my $sig = :($p, :$n, +@_); # set @_ = argument if it's a single list, else act like **@_
115115

116116
=head1 Parameter separators
117117

@@ -788,7 +788,7 @@ make routines that use them I<variadic>, and by extension are called variadic
788788
arguments. Here we will focus on slurpy parameters, or simply I<slurpies>.
789789

790790
An array or hash parameter can be
791-
marked as I<slurpy> by leading single (C<*>) or double asterisk (C<**>) or a
791+
marked as I<slurpy> by a leading single (C<*>) or double asterisk (C<**>) or a
792792
leading plus (C<+>). A slurpy parameter can bind to an arbitrary number of
793793
arguments (zero or more), and it will result in a type that is compatible
794794
with the sigil.
@@ -846,7 +846,7 @@ assign the value from each argument to those L<C<Scalar>|/type/Scalar>s. If the
846846
argument also had an intermediary L<C<Scalar>|/type/Scalar> it is bypassed during this process,
847847
and is not available inside the called function.
848848

849-
Sigiled parameters will always impose a context on the collected arguments.
849+
Sigiled parameters will always impose a L<context|/language/contexts> on the collected arguments.
850850
Sigilless parameters can also be used slurpily, preceded by a + sign, to
851851
work with whatever initial type they started with:
852852

@@ -863,7 +863,7 @@ as described in
863863
L<the section on slurpy array parameters|/language/signatures#Types_of_slurpy_array_parameters>.
864864

865865
L<Methods|/type/Method> automatically get a C<*%_> slurpy named parameter added if they
866-
don't have another slurpy named parameter declared.
866+
don't have one declared.
867867

868868
=head1 Types of slurpy array parameters
869869

@@ -873,11 +873,9 @@ There are three variations to slurpy array parameters.
873873

874874
=item The double-asterisk form C<**@> does not flatten arguments.
875875

876-
=item The plus form C<+@> flattens according to the single argument rule.
876+
=item The plus form C<+@> flattens according to the L<single argument rule|/language/list#Single_Argument_Rule>.
877877

878-
Each will be described in detail in the next few sections. As the difference
879-
between each is a bit nuanced, examples are provided for each to demonstrate how
880-
each slurpy convention varies from the others.
878+
We now describe each of them in detail.
881879

882880
=head2 X<Flattening slurpy: C<*@>|Syntax,*@>
883881

@@ -932,8 +930,8 @@ in the slurpy array.
932930
X<|Syntax,+ (Single argument rule slurpy)>
933931
=head2 Single argument rule slurpy: C<+@>
934932

935-
A slurpy parameter created using a plus engages the I<"single argument rule">,
936-
which decides how to handle the slurpy argument based upon context. Basically,
933+
A slurpy parameter created using a plus engages the L<single argument rule|/language/list#Single_Argument_Rule>,
934+
which decides how to handle the slurpy argument based on context. Basically,
937935
if only a single argument is passed and that argument is
938936
L<C<Iterable>|/type/Iterable>, that argument is used to fill the slurpy parameter
939937
array. In any other case, C<+@> works like C<**@>.

0 commit comments

Comments
 (0)