A pragma to use the C3 method resolution order algortihm
Version: 0.21Class::C3 is a pragma to use the C3 method resolution order algortihm.
License: Perl Artistic License
Operating System: Linux
Homepage: search.cpan.org
Developed by:
SYNOPSIS
package A;
use Class::C3;
sub hello { 'A::hello' }
package B;
use base 'A';
use Class::C3;
package C;
use base 'A';
use Class::C3;
sub hello { 'C::hello' }
package D;
use base ('B', 'C');
use Class::C3;
# Classic Diamond MI pattern
# < A >
# /
# < B > < C >
# /
# < D >
package main;
# initializez the C3 module
# (formerly called in INIT)
Class::C3::initialize();
print join ', ' => Class::C3::calculateMRO('Diamond_D') # prints D, B, C, A
print D->hello() # prints 'C::hello' instead of the standard p5 'A::hello'
D->can('hello')->(); # can() also works correctly
UNIVERSAL::can('D', 'hello'); # as does UNIVERSAL::can()
This is pragma to change Perl 5's standard method resolution order from depth-first left-to-right (a.k.a - pre-order) to the more sophisticated C3 method resolution order.