I'm using Moo and would like to override a default value for a
composed attribute after composing the role.

This works (with Moose as well):

use Moo;

package R {
    use Moo::Role;
    has a => ( is => 'ro', default => 2 );
}


package P {
    use Moo;
    with 'R';
    has '+a' => ( default => 3 );
}


say P->new->a;


AFAIK, the Moo (and Moose) documentation only mentions this syntax
when extending classes, not when composing roles.

Is this behavior simply a side effect of implementation, or is it
considered defined behavior?


Thanks,

Diab

Reply via email to