Skip to content

Commit 3e49ef7

Browse files
committed
Re-indexing "trait is default"
There was a bogus category generated, as well as some other problems. There's still a problem referenced in #1823 comments, but at least a new bogus category (which wasn't even in #1410) has been eliminated.
1 parent 6601343 commit 3e49ef7

File tree

4 files changed

+46
-41
lines changed

4 files changed

+46
-41
lines changed

doc/Language/functions.pod6

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,14 @@ happy-birthday( 'Jack', 25 ); # OUTPUT: «Happy 25th Birthday J
266266
267267
=end code
268268
269-
The first two versions of the C<happy-birthday> sub differs only in the arity (number of
270-
arguments), while the third version uses named arguments and is chosen only when named
271-
arguments are used, even if the arity is the same of another C<multi> candidate.
269+
The first two versions of the C<happy-birthday> sub differs only in the arity
270+
(number of arguments), while the third version uses named arguments and is
271+
chosen only when named arguments are used, even if the arity is the same of
272+
another C<multi> candidate.
272273
273-
When two sub have the same arity, the type of the arguments drive the dispatch; when
274-
there are named arguments they drive the dispatch even when their type is the same as another
275-
candidate:
274+
When two sub have the same arity, the type of the arguments drive the dispatch;
275+
when there are named arguments they drive the dispatch even when their type is
276+
the same as another candidate:
276277
277278
=begin code
278279
multi happy-birthday( Str $name, Int $age ) {
@@ -334,8 +335,8 @@ object:
334335
$congrats.congratulate('promotion','Cindy'); # OUTPUT: «Hooray for your promotion, Cindy␤»
335336
$congrats.congratulate('birthday','Bob'); # OUTPUT: «Happy birthday, Bob␤»
336337
337-
Unlike C<sub>, if you use named parameters with multi methods, the parameters must
338-
be required parameters to behave as expected.
338+
Unlike C<sub>, if you use named parameters with multi methods, the parameters
339+
must be required parameters to behave as expected.
339340
340341
Please note that a non-multi sub or operator will hide multi candidates of the
341342
same name in any parent scope or child scope. The same is true for imported
@@ -360,10 +361,11 @@ arguments. Consider this basic example:
360361
=for code :skip-test
361362
congratulate('being a cool number', 42); # Proto match error
362363
363-
The proto insists that all C<multi congratulate> conform to the basic signature of two strings,
364-
optionally followed by further parameters. The C<|> is an un-named C<Capture>
365-
parameter, and allows a C<multi> to take additional arguments. The first two calls
366-
succeed, but the third fails (at compile time) because C<42> doesn't match C<Str>.
364+
The proto insists that all C<multi congratulate> conform to the basic signature
365+
of two strings, optionally followed by further parameters. The C<|> is an
366+
un-named C<Capture> parameter, and allows a C<multi> to take additional
367+
arguments. The first two calls succeed, but the third fails (at compile time)
368+
because C<42> doesn't match C<Str>.
367369
368370
=for code :skip-test
369371
say &congratulate.signature # OUTPUT: «(Str $reason, Str $name, | is raw)␤»
@@ -402,13 +404,12 @@ many modules, will follow.
402404
403405
=head2 Slurpy Conventions
404406
405-
Perhaps the most important one of these conventions is the way slurpy list arguments are
406-
handled. Most of the time, functions will not automatically flatten
407-
slurpy lists.
408-
The rare exceptions are those functions that don't have a
409-
reasonable behavior on lists of lists (e.g., L<chrs|/routine/chrs>)
410-
or where there is a conflict with an established idiom (e.g., L<pop|/routine/pop>
411-
being the inverse of L<push|/routine/push>).
407+
Perhaps the most important one of these conventions is the way slurpy list
408+
arguments are handled. Most of the time, functions will not automatically
409+
flatten slurpy lists. The rare exceptions are those functions that don't have a
410+
reasonable behavior on lists of lists (e.g., L<chrs|/routine/chrs>) or where
411+
there is a conflict with an established idiom (e.g., L<pop|/routine/pop> being
412+
the inverse of L<push|/routine/push>).
412413
413414
If you wish to match this look and feel, any L<Iterable|/type/Iterable> argument must
414415
be broken out element-by-element using a C<**@> slurpy, with two nuances:
@@ -532,7 +533,7 @@ Routines are code objects that conform to L<type Routine|/type/Routine>, most
532533
notably L<Sub|/type/Sub>, L<Method|/type/Method>, L<Regex|/type/Regex> and
533534
L<Submethod|/type/Submethod>.
534535
535-
They carry additional functionality in addition to what L<Block|/type/Block>
536+
They carry extra functionality in addition to what L<Block|/type/Block>
536537
supplies: they can come as L<multis|#Multi-dispatch>,
537538
you can L<wrap|/type/Routine#method_wrap> them, and exit early with C<return>:
538539
@@ -550,7 +551,7 @@ you can L<wrap|/type/Routine#method_wrap> them, and exit early with C<return>:
550551
551552
Here, C<return> doesn't just leave the block inside which it was called, but
552553
the whole routine. In general, blocks are transparent to C<return>, they
553-
attach to the outer routine.
554+
attach to the outermost routine.
554555
555556
X<|use soft (pragma)>
556557
Routines can be inlined and as such provide an obstacle for wrapping. Use the
@@ -643,13 +644,13 @@ prefix the operator name with a C<&>-sigil.
643644
say "abc" ieq "Abc";
644645
# OUTPUT: «True␤»
645646
647+
X«|is tighter»X«|is equiv»X«|is looser»
646648
=head2 Precedence
647649
648-
X«|is tighter»X«|is equiv»X«|is looser»
649-
Operator precedence in Perl 6 is specified relatively to existing operators.
650-
The traits C<is tighter>, C<is equiv> and C<is looser> can be provided with an
651-
operator, the new operators precedence is related to. More than one trait can
652-
be applied.
650+
Operator precedence in Perl 6 is specified relatively to existing operators. The
651+
traits C<is tighter>, C<is equiv> and C<is looser> can be provided with an
652+
operator to indicate how the precedence of the new operators is related to
653+
other, existing ones. More than one trait can be applied.
653654
654655
For example, C«infix:<*>» has a tighter precedence than C«infix:<+>»,
655656
and squeezing one in between works like this:
@@ -740,12 +741,13 @@ class SomeClass does AnotherRole { ... }
740741
has $!another-attribute handles <close>;
741742
# ^^^^^^^ trait
742743
743-
... and also C<is tighter>, C<is looser>, C<is equiv> and C<is assoc> from the previous
744-
section.
744+
... and also C<is tighter>, C<is looser>, C<is equiv> and C<is assoc> from the
745+
previous section.
745746
746747
Traits are subs of the form C<< trait_mod<VERB> >>, where C<VERB> stands for the
747748
name like C<is>, C<does> or C<handles>. It receives the modified thing as
748-
argument, and the name as a named argument. See L<Sub|/type/Sub#Traits> for details.
749+
argument, and the name as a named argument. See L<Sub|/type/Sub#Traits> for
750+
details.
749751
750752
=begin code
751753
multi sub trait_mod:<is>(Routine $r, :$doubles!) {

doc/Type/Attribute.pod6

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ say $a.get_value($instance); # OUTPUT: «[1 2 3]␤»
3434
3535
=head1 Traits
3636
37-
=head2 X<Trait is default|is default (Attribute)>
37+
X<|is default (Attribute)>
38+
=head2 X<Trait is default>
3839
3940
An attribute that is assigned L<Nil|/type/Nil> will revert to its default value
4041
set with the trait C<is default>.

doc/Type/Routine.pod6

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Routine is also the level at which
1717
L<multiness|/language/glossary#Multi-Dispatch> (multi subs and multi methods)
1818
are handled.
1919
20-
=head2 X<Trait is default|is default (Routine)>
20+
X<|is default (Routine)>
21+
=head2 X<Trait is default>
2122
2223
There is a special trait for C<Routine>s called C<is default>. This trait is
2324
designed as a way to disambiguate C<multi> calls that would normally

doc/Type/Variable.pod6

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,10 @@ variable itself. The run-time class of a variable is L<Scalar>.
1313
Class C<Variable> holds the compile-time information that traits can use to
1414
introspect and manipulate variables.
1515
16-
=head1 Routines
16+
=head1 Traits
1717
18-
=head2 method name
19-
20-
method name(Variable:D: str)
21-
22-
Returns the name of the variable, including the sigil.
23-
24-
=head2 X<trait is default|is default (Variable)>
25-
26-
multi sub trait_mod:<is>(Variable:D, :$default!)
18+
X<|is default (Variable)>
19+
=head2 X<Trait is default>
2720
2821
Sets the default value with which a variable is initialized, and to which it
2922
is reset when L<Nil|/type/Nil> is assigned to it. Trait arguments are evaluated at compile
@@ -87,6 +80,14 @@ Sets the type constraint of a container bound to a variable.
8780
CATCH { default { say .^name, ' ', .Str } }
8881
# OUTPUT: «X::TypeCheck::Assignment Type check failed in assignment to $i; expected Int but got Str ("forty plus two")␤»
8982
83+
=head1 Methods
84+
85+
=head2 method name
86+
87+
method name(Variable:D: str)
88+
89+
Returns the name of the variable, including the sigil.
90+
9091
=end pod
9192

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

0 commit comments

Comments
 (0)