-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 =pod Summary? You can do it! I wrote a test script to try this: lang:Perl package A; sub a { print "A->a\n" } package B; use Class::C3; @B::ISA = ('A'); sub a { print "B->a\n"; $_[0]->next::method(); } At this point, everything is fine. C<< B->a >> prints C<< B->a, A->a >>. Now, let's add C to the mix: package C; use NEXT; @C::ISA = ('A'); sub a { print "C->a\n"; $_[0]->NEXT::a; } package D; use NEXT; @D::ISA = ('B', 'C'); sub a { print "D->a\n"; $_[0]->NEXT::a; } If we call C<< C->a >>, we get the expected output. If we call C<< D->a >>, we still get the expected output, C<< D->a C->a B->a A->a >>. I intiutively knew that this would work (my Catalyst stuff does it), but now I am convinced that I never need to see NEXT again. Here's a quick driver for experimentation: do { print "$_:\n"; $_->a; print "\n"; } for qw/A B C D/; Something to do if you want to see how SUPER breaks things: package B; @B::ISA = ('A'); sub a { print "B->a\n"; $_[0]->SUPER::a; } Now C<< B->a >> never dispatches to C<< C->a >>, it goes right up to A. Ouch. While I'm on the topic, here's a cool feature of Class::C3: use Class::C3; package A; sub a { print "A->a\n"; } package B; sub a { print "B->a\n"; $_[0]->maybe::next::method; } package C; @C::ISA = ('A'); sub a { print "C->a\n"; $_[0]->maybe::next::method; } package D; @D::ISA = ('B'); sub a { print "D->a\n"; $_[0]->next::method(); } do { print "$_:\n"; $_->a; print "\n"; } for qw/A B C D/; You can see here that D isa B, and B isa UNIVERSAL (and nothing else). C<< D->a >> prints: D: D->a B->a Which is what you'd expect. However, if you had just used C in B, it would die because there was no next method. Why call C at all though? Because you can just add this line: @D::ISA = ('B', 'C'); And you're back to: D: D->a B->a C->a A->a Without changing any code outside of your calling package. Neat. (The real-world application of this is Catalyst plugins.) Oh, and now for a rant. A lot of people think Perl's object system sucks, but they're wrong. Perl's object system (with C) can do anything, and is about the same as CLOS. =cut -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iQCVAwUBRtvI4dAZeFPdJeQvAQIaXwP+Ld8RRHOV1AS3rFnqN1TZAZv7nG8oTvRg zb7CXVZtP6UJ5OXkXB2yFHZDt9of5QzuRLI1zawcRghv+JgYdGgg6HntMPJ0WdW0 LKneaxy8m+AA1l+/O3dwNuOj+jXl2gmNaB6ep5mr31B3r9uEL6ov4L8h2FhX+mlt Tsrwhcy9lWY= =MEV5 -----END PGP SIGNATURE-----