[Wellington-pm] Class::C3 - sane method dispatch in the face of Multiple Inheritance

Sam Vilain sam at vilain.net
Tue Nov 15 12:41:45 PST 2005


Stevan Little has an interesting distribution on CPAN;

  http://search.cpan.org/dist/Class-C3/lib/Class/C3.pm

This module is all about making multiple inheritance work better, by
defining what happens when you call ->SUPER::foo (instead, you call
->next::method, which is similar to CLOS' call-next-method or Dylan's
next-method) in a way that prevents superclasses ever being dispatched
to before their subclasses.

The Catalyst framework has been using a similar system - Damian Conway's
NEXT - for quite a while; and the differences between NEXT and Class::C3
are subtle, as months of heated debate on perl6-language will attest to.
Perl 6 is likely to use C3 by default, with a class trait in the
specification to select an alternate dispatch mechanism.  DBIx::Class is
experimentally using C3, and it is likely that the next major version of
Catalyst might, too.

Just to pre-empt a possible flamewar, remember that inheritance is not
about what objects *are*, it's about what they *do*.  This change in
perspective takes the steam out of most of the anti-multiple inheritance
arguments.  Or at least shuts up the person you're talking to for long
enough for you to duck away.

Sam.



More information about the Wellington-pm mailing list