Skip to content

Commit

Permalink
[subs] rip out section about multi methods; it belongs into the OO ch…
Browse files Browse the repository at this point in the history
…apter, and probably with quite different wording
  • Loading branch information
moritz committed Aug 23, 2010
1 parent a64178f commit 8746dbc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
6 changes: 6 additions & 0 deletions src/classes-and-objects.pod
Expand Up @@ -473,3 +473,9 @@ there a good way to guarantee, in Perl 6, that the attribute C<$!started>
gets checked-and-set atomically?

=end

=for authors

TODO: Optiionally talk about multi methods

=end authors
29 changes: 0 additions & 29 deletions src/multi-dispatch.pod
Expand Up @@ -518,35 +518,6 @@ as C<only sub YourSub>. At the time of writing, no compiler supports this.

=end sidebar

=head1 Multi Methods

X<multimethods>
X<methods; multidispatch>

Methods can participate in dispatch just as do subroutines. For multi method
dispatch the invocant acts as a positional parameter.

The main difference between sub and method calls is where the dispatcher
searches for the routines: it looks for subroutines in the current and outer
lexical scopes, whereas it looks for methods in the class of the invocant and
recursively in any parent classes.

=for author

# XXX should this explanation moved to the OO tutorial?
# XXX jnthn: in my opinion, yes

# TODO: Multi method dispatch example

=end for

Unlike subroutine dispatch, you can dispatch to multiple candidates with
multimethods. The C<$object.?method> syntax dispatches to zero or one matching
candidates; it is no error if there is no matching candidate.
C<$object.*method> calls I<all> matching candidates, but it is no error if
there are no matching candidates. C<$object.+method> calls at least one
matching candidate.

=head1 Toying with the candidate list

Each multi dispatch builds a list of candidates, all of which satisfy the
Expand Down

0 comments on commit 8746dbc

Please sign in to comment.