Skip to content

Commit aede24b

Browse files
committed
Changes anchors and de-capitalizes headers #2223 #1303
1 parent 7adf41f commit aede24b

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

doc/Language/functions.pod6

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ types of arguments, and the return value.
2020
2121
Introspection on subroutines is provided via L<C<Routine>|/type/Routine>.
2222
23-
=head1 Defining/Creating/Using Functions
23+
=head1 Defining/Creating/Using functions
2424
2525
=head2 X<Subroutines|declarator,sub>
2626
@@ -100,7 +100,7 @@ Or even
100100
say { $^a ** 2 + $^b ** 2 }(3, 4) # OUTPUT: «25␤»
101101
102102
103-
=head2 X«Blocks and Lambdas|syntax,->»
103+
=head2 X«Blocks and lambdas|syntax,->»
104104
105105
Whenever you see something like C«{ $_ + 42 }»,
106106
C«-> $a, $b { $a ** $b }», or C«{ $^text.indent($:spaces) }», that's
@@ -128,7 +128,7 @@ sub formatB<(Str $s)> { ... }
128128
Details about the syntax and use of signatures can be found in the
129129
L<documentation on the C<Signature> class|Signature>.
130130
131-
=head3 Automatic Signatures
131+
=head3 Automatic signatures
132132
133133
X<|@_>X<|%_>
134134
If no signature is provided but either of the two automatic variables C<@_> or
@@ -202,7 +202,7 @@ values.
202202
put b.perl;
203203
# OUTPUT: «\("a", "b", "c")␤»
204204
205-
=head2 Return Type Constraints
205+
=head2 Return type constraints
206206
207207
Perl 6 has many ways to specify a function's return type:
208208
@@ -427,13 +427,13 @@ at /tmp/hDM1N2OAOo:1
427427
Anonymous sub cannot be declared C<only>. C<only sub {}'> will throw an error of
428428
type, surprisingly, C<X::Anon::Multi>.
429429
430-
=head1 Conventions and Idioms
430+
=head1 Conventions and idioms
431431
432432
While the dispatch system described above provides a lot of flexibility,
433433
there are some conventions that most internal functions, and those in
434434
many modules, will follow.
435435
436-
=head2 Slurpy Conventions
436+
=head2 Slurpy conventions
437437
438438
Perhaps the most important one of these conventions is the way slurpy list
439439
arguments are handled. Most of the time, functions will not automatically
@@ -490,7 +490,7 @@ grab($b); # OUTPUT: «grab 1␤grab 2␤»
490490
my \c = (1, 2); # Sigilless variables always bind, even with '='
491491
grab(c); # OUTPUT: «grab 1␤grab 2␤»
492492
493-
=head1 Functions are First-Class Objects
493+
=head1 Functions are first-class objects
494494
495495
Functions and other code objects can be passed around as values, just like any
496496
other object.
@@ -519,7 +519,7 @@ which applies a function to each input element:
519519
my @squared = map &square, 1..5;
520520
say join ', ', @squared; # OUTPUT: «1, 4, 9, 16, 25␤»
521521
522-
=head2 Z<>Infix Form
522+
=head2 Z<>Infix form
523523
524524
To call a subroutine with 2 arguments like an infix operator, use a subroutine
525525
reference surrounded by C<[> and C<]>.
@@ -528,6 +528,7 @@ reference surrounded by C<[> and C<]>.
528528
say 21 [&plus] 21;
529529
# OUTPUT: «42␤»
530530
531+
X<|closures>
531532
=head2 Closures
532533
533534
All code objects in Perl 6 are I<closures>, which means they can reference
@@ -542,12 +543,12 @@ lexical variables from an outer scope.
542543
$generated(); # OUTPUT: «42␤»
543544
544545
Here, C<$y> is a lexical variable inside C<generate-sub>, and the inner
545-
subroutine that is returned uses it. By the time that the inner sub is called,
546+
subroutine that is returned uses it. By the time that inner sub is called,
546547
C<generate-sub> has already exited. Yet the inner sub can still use C<$y>,
547548
because it I<closed> over the variable.
548549
549-
Another closure example is the use of L<map|/type/List#routine_map>
550-
to multiply a list of numbers:
550+
Another closure example is the use of L<map|/type/List#routine_map> to multiply
551+
a list of numbers:
551552
552553
my $multiply-by = 5;
553554
say join ', ', map { $_ * $multiply-by }, 1..5; # OUTPUT: «5, 10, 15, 20, 25␤»
@@ -614,7 +615,7 @@ pragma C<use soft;> to prevent inlining to allow wrapping at runtime.
614615
615616
=comment Important ones: candidates, wrap, unwrap, assuming, arity, count
616617
617-
=head1 Defining Operators
618+
=head1 Defining operators
618619
619620
Operators are just subroutines with funny names. The funny names are composed
620621
of the category name (C<infix>, C<prefix>, C<postfix>, C<circumfix>,
@@ -964,9 +965,8 @@ multi a(Int $x) {
964965
say (a 10); # OUTPUT: «36288002␤»
965966
=end code
966967
967-
=head2 sub nextcallee
968-
969968
X<|dispatch,nextcallee>
969+
=head2 sub nextcallee
970970
971971
Redispatch may be required to call a block that is not the current scope what
972972
provides C<nextsame> and friends with the problem to referring to the wrong
@@ -997,9 +997,9 @@ executed in parallel, after some timeout, and then returns. We can't use
997997
C<nextsame> here, because it'd be trying to C<nextsame> the Promise's block
998998
instead of our original routine.
999999
1000-
=head2 wrapped routines
1001-
10021000
X<|dispatch,wrapped routines>
1001+
=head2 Wrapped routines
1002+
10031003
10041004
Besides those are mentioned above, re-dispatch is helpful in more situations.
10051005
One is for dispatching to wrapped routines:
@@ -1020,7 +1020,7 @@ say square-root(4); # OUTPUT: «2␤»
10201020
say square-root(-4); # OUTPUT: «0+2i␤»
10211021
=end code
10221022
1023-
=head2 routines of parent class
1023+
=head2 Routines of parent class
10241024
10251025
Another use case is to re-dispatch to methods from parent classes.
10261026
@@ -1035,7 +1035,7 @@ class LoggedVersion is Version {
10351035
say LoggedVersion.new('1.0.2');
10361036
=end code
10371037
1038-
=head1 Coercion Types
1038+
=head1 Coercion types
10391039
10401040
Coercion types force a specific type for routine arguments while allowing
10411041
the routine itself to accept a wider input. When invoked, the arguments are
@@ -1112,16 +1112,15 @@ for (2,4) X (1,2) -> ($a,$b) {
11121112
In this case, we are coercing an C<Int> to a C<Bool>, which is then printed (put
11131113
into a string context) in the C<for> loop that calls the function.
11141114
1115-
=head1 sub MAIN
1116-
11171115
X<|MAIN>X<|command line arguments>
1116+
=head1 sub MAIN
11181117
1119-
The sub with the special name C<MAIN> is executed after all relevant phasers. Its signature is the means by which command line arguments can be
1120-
parsed. Multi methods are supported and a usage method is automatically
1121-
generated and displayed if no command line arguments are provided. All command
1122-
line arguments are also available in
1123-
L<C<@*ARGS>|/language/variables#Dynamic_variables>, which can be mutated before
1124-
being processed by C<MAIN>.
1118+
The sub with the special name C<MAIN> is executed after all relevant phasers.
1119+
Its signature is the means by which command line arguments can be parsed. Multi
1120+
methods are supported and a usage method is automatically generated and
1121+
displayed if no command line arguments are provided. All command line arguments
1122+
are also available in L<C<@*ARGS>|/language/variables#Dynamic_variables>, which
1123+
can be mutated before being processed by C<MAIN>.
11251124
11261125
Unlike other ordinary functions, any return value provided by C<MAIN> will be
11271126
ignored by the invoker, even if explicitly set by means of a C<return> statement
@@ -1213,7 +1212,7 @@ unit sub MAIN( Int :$length = 24,
12131212
Note that this is only appropriate if you do not need a C<proto> or C<multi> definition.
12141213
12151214
X<|USAGE>X<|$*USAGE>
1216-
=head1 sub USAGE
1215+
=head1 sub C<USAGE>
12171216
12181217
If no multi candidate of C<MAIN> is found for the given command line
12191218
parameters, the sub C<USAGE> is called. If no such method is found,

0 commit comments

Comments
 (0)