Skip to content

Instantly share code, notes, and snippets.

@marcoarthur
Created September 21, 2016 12:18
Show Gist options
  • Save marcoarthur/191567420dbdaac9b6b92679e788d620 to your computer and use it in GitHub Desktop.
Save marcoarthur/191567420dbdaac9b6b92679e788d620 to your computer and use it in GitHub Desktop.
package T;
use Moose::Role;
sub a { 'x' }
sub b { 'y' }
sub c { shift->i }
package U;
use Moose::Role;
sub c { 'q' }
sub d { 'r' }
package TU;
use Moose::Role;
with 'T', 'U';
package My::Class;
use Moose;
with 'TU';
sub i { 'self->i' };
# sub c { 'my c' }; # Adding c cease the error shown in [Note 1]
package main;
use Modern::Perl;
use My::Class;
my $c = My::Class->new();
say $c->a;
say $c->b;
say $c->c;
say $c->d;
say $c->i;
__END__
Following [1], we are testing method conflict marker, with two traits adition:
T + U, both having message c() implemented.
Moose have so implemented the traits aditions the same way the paper describes,
with the resolution to mark the conflict method "c" in T + U.
And generates the following error:
[Note 1]
`` Due to a method name conflict in roles 'T' and 'U', the method 'c' must be
implemented or excluded by 'My::Class' at
/home/itaipu/perl5/lib/perl5/x86_64-linux-gnu-thread-multi/Moose/Exporter.pm
line 419 ''
Bibliography:
[1] A. P. Black, N. Schärli, and S. Ducasse, “Applying traits to the smalltalk
collection classes,” in ACM SIGPLAN Notices, 2003, vol. 38, pp. 47–64.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment