On 30 March 2013 08:10, Chris Prather <[email protected]> wrote:
> Excludes specifically (silently) encourages people to break the
> contract nature (allomorphism?) of Roles. That is you can suddenly no
> longer have an API that the Role claims you *should* have because you
> excluded the method on composition. Additionally the excludes/alias
> feature *only* exists for Roles in the core.
That sounds like the usage of alias/excludes should have a default
stricture that they may be only used if-and-only-if doing so doesn't
break the role criteria.
So alias/excluding "foo" out of the picture should add a < requires
foo > equivalent to the role that has to be resolved at some later
stage somehow.
at least, that way, people can use it for "useful" purposes without it
resulting in an interface contract breach.
Sample Usage Might be:
-
package A;
use Moose::Role;
sub foo { };
-
package B;
use Moose::Role;
with 'B' => { excludes => [ 'foo' ] }
-
package C;
use Moose;
with 'B; # C must declare 'foo'
-
Or with Aliases;
-
package A;
use Moose::Role;
sub foo { };
-
package B;
use Moose::Role;
with 'B' => { alias => { 'foo' => 'A_Foo' } }
sub B_Foo { }
-
package C;
use Moose;
with 'B; # C must declare 'foo'
sub foo { $_[0]->A_Foo + $_[0]->B_Foo }
--
kentnl