Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Mention BUILDALL overriding in object construction
  • Loading branch information
moritz committed Feb 20, 2015
1 parent e354b41 commit 7e45e2d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/Language/objects.pod
Expand Up @@ -419,6 +419,24 @@ Another thing to note is that the name C<new> is not special in Perl 6. It
is merely a common convention. You can call C<bless> from any method at all,
or use C<CREATE> to fiddle around with low-level workings.
Another pattern of hooking into object creation is by writing your own method
C<BUILDALL>. To make sure that initialization of superclasses works fine, you
need to C<callsame> to invoke the parent classes C<BUILDALL>.
=begin code
class MyClass {
method BUILDALL(|) {
# initial things here
callsame; # call the parent classes (or default) BUILDALL
# you can do final checks here.
}
}
=end code
=comment TODO: better example for BUILDALL overriding
=head1 X<Roles|declarator,role>
Roles are in some ways similar to classes, in that they are a collection of
Expand Down

0 comments on commit 7e45e2d

Please sign in to comment.