summaryrefslogtreecommitdiff
path: root/lib/NEXT/README
blob: 471b2bb79698bf35167fc8d6f2af00fd6c7fe49b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
==============================================================================
                       Release of version 0.02 of NEXT
==============================================================================


NAME

    NEXT - Pseudo class for method redispatch


DESCRIPTION

    NEXT.pm adds a pseudoclass named C<NEXT> to any program that
    uses it. If a method C<m> calls C<$self->NEXT::m()>, the call to
    C<m> is redispatched as if the calling method had not originally
    been found.

    In other words, a call to C<$self->NEXT::m()> resumes the
    depth-first, left-to-right search of parent classes that
    resulted in the original call to C<m>.

    Note that this is not the same thing as C<$self->SUPER::m()>, which
    begins a new dispatch that is restricted to searching the ancestors
    of the current class. C<$self->NEXT::m()> can backtrack past
    the current class -- to look for a suitable method in other
    ancestors of C<$self> -- whereas C<$self->SUPER::m()> cannot.

    An particularly interesting use of redispatch is in
    C<AUTOLOAD>'ed methods. If such a method determines that it is
    not able to handle a particular call, it may choose to
    redispatch that call, in the hope that some other C<AUTOLOAD>
    (above it, or to its left) might do better.

    Note that it is a fatal error for any method (including C<AUTOLOAD>)
    to attempt to redispatch any method except itself. For example:

            sub D::oops { $_[0]->NEXT::other_method() } # BANG!


AUTHOR

    Damian Conway (damian@conway.org)


COPYRIGHT

	 Copyright (c) 2000-2001, Damian Conway. All Rights Reserved.
	 This module is free software. It may be used, redistributed
	    and/or modified under the same terms as Perl itself.


==============================================================================

CHANGES IN VERSION 0.02


	- Fixed setting of $AUTOLOAD in NEXT'd AUTOLOADS (thanks Leonid)

	- Changed licence for inclusion in core distribution


==============================================================================

AVAILABILITY

NEXT has been uploaded to the CPAN
and is also available from:

	http://www.csse.monash.edu.au/~damian/CPAN/NEXT.tar.gz

==============================================================================