The Moose 2.1201 pod seems to say it is defined behavior:
has +$name => %options
This is variation on the normal attribute creator "has" which
allows you to clone and extend an attribute from a superclass or
from a role. Here is an example of the superclass usage: ...
Given that Moo is supposed to be Moose-compatible, the same
seems likely true for Moo.
--Chris
On Tue, Jul 22, 2014 at 5:16 PM, Diab Jerius <[email protected]> wrote:
> 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