> Moose roles have some limitations, such as inability to override a
method in a class which "with"es the role.

This is false. For example:

{
    package MyRole;
    use Moose::Role;
    sub foo {
        'I came from the role';
    }
}

{
    package MyClass;
    use Moose;
    with 'MyRole';
    around foo => sub {
      'I came from the class';
    };
}

use 5.010;
my $obj = MyClass->new;
say $obj->foo;
​  ​
# prints: I came from the class




On Wed, Aug 10, 2016 at 6:00 AM, Victor Porton <[email protected]> wrote:

> Moose roles have some limitations, such as inability to override a
> method in a class which "with"es the role.
>
> But I can use an abstract base class instead of a role.
>
> Are there any real situations where roles are better than base classes?
> With examples, please.
>

Reply via email to