Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
doc is trait in typesystem
  • Loading branch information
gfldex committed Jun 16, 2016
1 parent ff74bc4 commit d6ca213
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion doc/Language/typesystem.pod
Expand Up @@ -57,7 +57,34 @@ be searched use a C<HyperWhatever>.
=head3 trait C<is>
TODO
Defined as:
multi sub trait_mod:<is>(Mu:U $child, Mu:U $parent)
The trait X<C<is>|is (inheritance)> accepts a type object to be
added as a parent class of a class in it's definition. To allow multiple
inheritance the trait can be applied more then once. Adding parents to a class
will import their methods into the target class. If the same method name occurs
in multiple parents, the first added parent will win.
If no C<is> trait is provided the default of L<C<Any>|/type/Any)> will be used
as a parent class. This forces all Perl 6 objects to have the same set of basic
methods to provide an interface for introspection and coercion to basic types.
class A {
multi method from-a(){ 'A::from-a' }
}
dd A.new.^parents(:all);
# OUTPUT«(Any, Mu)␤»
class B {
method from-b(){ 'B::from-b ' }
multi method from-a(){ 'B::from-A' }
}
class C is A is B {}
dd C.new.from-a();
# OUTPUT«"A::from-a"␤»
=head3 trait C<is required>
Expand Down

0 comments on commit d6ca213

Please sign in to comment.