Skip to content

Commit 4088900

Browse files
committed
explain coersion and hint at Cool
1 parent 52fab9f commit 4088900

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/Language/typesystem.pod6

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ L<//|/language/operators#infix_//>,
5353
L<with/without|/language/control#with,_orwith,_without> and
5454
L<signatures|/type/Signature#Constraining_Defined_and_Undefined_Values>.
5555
56+
=head3 Coersion
57+
58+
Turning one type into another is done with coersion methods that have the same
59+
name then the target type. This convention is made mandatory by
60+
L<Signatures|/type/Signature#Coercion_Type>. The source type has to know how to
61+
turn itself into the target type. To allow build-in types to turn themself into
62+
user defined types use L<augment|/language/variables#The_augment_Declarator>.
63+
64+
Perl 6 provides methods defined in L<Cool|/type/Cool> to convert to a target
65+
type before applying further operations. Most build-in types decend from
66+
C<Cool> and as such may provide implicit coersion that may be undesired. It is
67+
the responsibility of the user to care about trap-free usage of those
68+
methods.
69+
5670
=head1 Type Declarators
5771
5872
Type declarators introduce a new type into the given scope. Nested scopes can

0 commit comments

Comments
 (0)