Class-Multimethods-Pure
view release on metacpan or search on metacpan
lib/Class/Multimethods/Pure.pm view on Meta::CPAN
multi foo => ('Kunction', 'Object') => sub {...}
multi foo => ('Object', 'Kunction') => sub {...}
multi foo => ('Kunction', 'Kunction') => sub {...}
Now they're both combinators, but the module yells at you if you pass
(Kunction, Junction), because there are two methods that would satisfy
that.
The way to define precedence with these combinators is similar to the
way you define precedence in a recursive descent grammar. You create a
cascade of empty classes at the top of your heirarchy, and derive each
of your generics from a different one of those:
package AnyObject;
package JunctionObject;
use base 'AnyObject';
package KunctionObject;
use base 'JunctionObject';
package Object;
use base 'KunctionObject';
# derive all other classes from Object
( run in 1.628 second using v1.01-cache-2.11-cpan-49f99fa48dc )