Skip to content

Commit 20b68d2

Browse files
committed
Rephrase slightly Slurpy (function) Conventions.
Links to types whenever possible.
1 parent e0d5770 commit 20b68d2

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

doc/Language/functions.pod6

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -344,33 +344,34 @@ many modules, will follow.
344344
345345
=head2 Slurpy Conventions
346346
347-
Perhaps the most important of these is the way slurpy list arguments are
347+
Perhaps the most important one of these conventions is the way slurpy list arguments are
348348
handled. Most of the time, functions will not automatically flatten
349-
slurpy lists. The rare exceptions are those functions that don't have a
350-
reasonable behavior on lists of lists; for example, L<chrs|/routine/chrs>,
351-
or where there is a conflict with an established idiom, like L<pop|/routine/pop>
352-
being the inverse of L<push|/routine/push>.
349+
slurpy lists.
350+
The rare exceptions are those functions that don't have a
351+
reasonable behavior on lists of lists (e.g., L<chrs|/routine/chrs>)
352+
or where there is a conflict with an established idiom (e.g., L<pop|/routine/pop>
353+
being the inverse of L<push|/routine/push>).
353354
354-
If you wish to match this look and feel, any Iterable argument must
355-
be broken out element-by-element using a **@ slurpy, with two nuances:
355+
If you wish to match this look and feel, any L<Iterable|/type/Iterable> argument must
356+
be broken out element-by-element using a C<**@> slurpy, with two nuances:
356357
357-
=item An Iterable inside a L<Scalar container|/language/containers#Scalar_containers> doesn't count.
358+
=item An L<Iterable|/type/Iterable> inside a L<Scalar container|/language/containers#Scalar_containers> doesn't count.
358359
359-
=item Lists created with a L<C<,>|/routine/,> at the top level only count as one Iterable.
360+
=item L<List|/type/List>s created with a L<C<,>|/routine/,> at the top level only count as one L<Iterable|/type/Iterable>.
360361
361362
This can be achieved by using a slurpy with a C<+> or C<+@> instead of C<**>:
362363
363364
sub grab(+@a) { "grab $_".say for @a }
364365
365-
...which is shorthand for something very close to:
366+
which is shorthand for something very close to:
366367
367368
multi sub grab(**@a) { "grab $_".say for @a }
368369
multi sub grab(\a) {
369370
a ~~ Iterable and a.VAR !~~ Scalar ?? nextwith(|a) !! nextwith(a,)
370371
}
371372
372-
This results in the following behavior, which is known as the "single
373-
argument rule" and is important to understand when invoking slurpy functions:
373+
This results in the following behavior, which is known as the
374+
I<"single argument rule"> and is important to understand when invoking slurpy functions:
374375
375376
=for code :preamble<sub grab(+@a) {};>
376377
grab(1, 2); # OUTPUT: «grab 1␤grab 2␤»
@@ -388,7 +389,7 @@ grab(flat (1, 2)); # OUTPUT: «grab 1␤grab 2␤»
388389
grab(flat $(1, 2)); # OUTPUT: «grab 1␤grab 2␤»
389390
390391
It's worth noting that mixing binding and sigilless variables
391-
in these cases requires a bit of finesse, because there is no Scalar
392+
in these cases requires a bit of finesse, because there is no L<Scalar|/type/Scalar>
392393
intermediary used during binding.
393394
394395
=for code :preamble<sub grab(+@a) {};>

0 commit comments

Comments
 (0)