Skip to content

Commit 39575cc

Browse files
committed
Adds target destination and some reflow
Added back /syntax/role, which disappeared due to obscure indexing rules (see #2575). Either when indexing for `does` was added (apparently, adding an index term behind or before a header suppresses the creation of a new page), or simply when the X<|declarator,role> was changed, it disappeared. It's added back, refs #2568
1 parent 053715b commit 39575cc

File tree

3 files changed

+39
-35
lines changed

3 files changed

+39
-35
lines changed

doc/Language/objects.pod6

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,9 @@ say RectangleWithCachedArea.new( x2 => 5, x1 => 1, y2 => 1, y1 => 0).area;
669669
670670
=head2 Object cloning
671671
672-
The cloning is done using the L<clone|/routine/clone> method available on all objects, which
673-
shallow-clones both public and private attributes. New values for I<public>
674-
attributes can be supplied as named arguments.
672+
The cloning is done using the L<clone|/routine/clone> method available on all
673+
objects, which shallow-clones both public and private attributes. New values for
674+
I<public> attributes can be supplied as named arguments.
675675
676676
=begin code
677677
class Foo {
@@ -685,43 +685,47 @@ attributes can be supplied as named arguments.
685685
say $o2; # Foo.new(foo => 42, bar => 5000)
686686
=end code
687687
688-
See document for L<clone|/routine/clone> for details on how non-scalar attributes get cloned,
689-
as well as examples of implementing your own custom clone methods.
688+
See document for L<clone|/routine/clone> for details on how non-scalar
689+
attributes get cloned, as well as examples of implementing your own custom clone
690+
methods.
690691
691-
=head1 The X<role> declarator
692-
X<|does>
692+
=head1 X<Roles|declarator,role>
693693
694694
Roles are a collection of attributes and methods; however, unlike classes, roles
695695
are meant for describing only parts of an object's behavior; this why, in
696696
general, roles are intended to be I<mixed in> classes and objects. In general,
697697
classes are meant for managing objects and roles are meant for managing behavior
698698
and code reuse within objects.
699699
700-
=begin code
701-
use MONKEY-SEE-NO-EVAL;
702-
role Serializable {
703-
method serialize() {
704-
self.perl; # very primitive serialization
705-
}
706-
method deserialize($buf) {
707-
EVAL $buf; # reverse operation to .perl
708-
}
709-
}
700+
X<|does> Roles use the keyword C<role> preceding the name of the role that is
701+
declared. Roles are mixed in using the C<does> keyword preceding the name of the
702+
Role that is mixed in.
710703
711-
class Point does Serializable {
712-
has $.x;
713-
has $.y;
704+
=begin code
705+
use MONKEY-SEE-NO-EVAL;
706+
role Serializable {
707+
method serialize() {
708+
self.perl; # very primitive serialization
714709
}
715-
my $p = Point.new(:x(1), :y(2));
716-
my $serialized = $p.serialize;
717-
my $clone-of-p = Point.deserialize($serialized);
718-
say $clone-of-p.x; # OUTPUT: «1␤»
719-
=end code
710+
method deserialize($buf) {
711+
EVAL $buf; # reverse operation to .perl
712+
}
713+
}
714+
715+
class Point does Serializable {
716+
has $.x;
717+
has $.y;
718+
}
719+
my $p = Point.new(:x(1), :y(2));
720+
my $serialized = $p.serialize;
721+
my $clone-of-p = Point.deserialize($serialized);
722+
say $clone-of-p.x; # OUTPUT: «1␤»
723+
=end code
720724
721725
Roles are immutable as soon as the compiler parses the closing curly brace of
722726
the role declaration.
723727
724-
=head2 Application of role
728+
=head2 Applying roles
725729
726730
Role application differs significantly from class inheritance. When a role
727731
is applied to a class, the methods of that role are copied into the class.

doc/Language/operators.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2585,7 +2585,7 @@ precedence.
25852585
25862586
Short-circuits so that it returns the first operand that evaluates to
25872587
C<False>, otherwise returns the last operand. Note that C<and> is easy
2588-
to misuse. See L<traps|/language/traps#Loose_boolean_operators>.
2588+
to misuse, see L<traps|/language/traps#Loose_boolean_operators>.
25892589
25902590
=head2 infix X<C«andthen»>
25912591

doc/Type/Cool.pod6

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
77
class Cool is Any { }
88
9-
C<Cool>, also known as the B<C>onvenient B<OO> B<L>oop, is a base class
10-
employed by a number of built-in classes whose instances can be meaningfully
11-
coerced to a string and a number. For example, an L<Array|/type/Array> can be used
12-
in mathematical operations, where its numerical representation is the
13-
number of elements it contains. At the same time, it can be concatenated
14-
to a string, where its stringy representation is all of its elements
15-
L<joined|/routine/join> by a space. Because L<Array|/type/Array> is L<Cool|/type/Cool>, the
16-
appropriate coercion happens automatically.
9+
C<Cool>, also known as the B<C>onvenient B<OO> B<L>oop, is a base class employed
10+
by a number of built-in classes whose instances can be meaningfully coerced to a
11+
string and a number. For example, an L<Array|/type/Array> can be used in
12+
mathematical operations, where its numerical representation is the number of
13+
elements it contains. At the same time, it can be concatenated to a string,
14+
where its stringy representation is all of its elements L<joined|/routine/join>
15+
by a space. Because L<Array|/type/Array> is L<Cool|/type/Cool>, the appropriate
16+
coercion happens automatically.
1717
1818
Methods in C<Cool> coerce the invocant to a more specific type, and then call
1919
the same method on that type. For example both L<Int|/type/Int> and L<Str|/type/Str> inherit from

0 commit comments

Comments
 (0)