4 ms·
I know you're being sarcastic, but here's some contrived MI that shows common behaviour that can in independent taxanomic branches not polluting the inheritance
by singingfish 11y ago
I know you're being sarcastic, but here's some contrived MI that shows common behaviour that can in independent taxanomic branches not polluting the inheritance tree [Edit, added a Bird class]:
#!/usr/bin/env perl
package Flying;
use Moo::Role;
sub flap {
# do stuff;
}
1;
package Bat;
use Moo;
with 'Flying';
has wings => (
is => 'ro',
default => 2,
);
1;
package FruitBat;
use Moo;
extends 'Bat';
1;
package Bird;
use Moo;
with 'Flying';
# Implementation left to the reader.
1;
use warnings;
use strict;
use mro;
use Bat;
use FruitBat;
use Data::Dumper;
print Dumper mro::get_linear_isa('Bat');
print Dumper mro::get_linear_isa('FruitBat');
print Dumper mro::get_linear_isa('Bird');
__END__
$ perl /tmp/demo.pl
$VAR1 = [
'Bat',
'Moo::Object'
];
$VAR1 = [
'FruitBat',
'Bat',
'Moo::Object'
];
$VAR1 = [
'Bird',
'Moo::Object'
];