RE: nested roles are badly limited

[email protected] (John Macdonald) Sat, 22 Nov 2014 13:53:44 +0000
Newsgroups perl.moose
Message-ID <[email protected]>
Yes, that was one of my three examples.=0A=
=0A=
Doing it that way means there are two problems:=0A=
=0A=
1. ARole cannot encapsulate the entire interface - every consumer of ARole =
has to explicitly consume ARole and BRole.  Not only that, every consumer o=
f ARole has to consume them in the right order - they have to support the i=
nternal implementation detail of ARole in two different ways that a fully e=
ncapsulated interface would hide completely.  Suppose ARole is updated to u=
se an alternate BPlusRole for its needs - now you have to find every consum=
er of ARole and change how they load ARole. =0A=
=0A=
2. Additionally, every consumes has to consume ARole and BRole in two separ=
ate "with" statements - losing the cross-checking that with provides (for c=
onflicting method/attribute names).=0A=
=0A=
John Macdonald=0A=
Software Engineer=0A=
=0A=
Ontario Institute for Cancer Research=0A=
MaRS Centre=0A=
=0A=
661 University Avenue=0A=
=0A=
Suite 510=0A=
Toronto, Ontario=0A=
=0A=
Canada M5G 0A3=0A=
=0A=
=0A=
Tel:=0A=
=0A=
Email: [email protected]=0A=
=0A=
Toll-free: 1-866-678-6427=0A=
Twitter: @OICR_news=0A=
=0A=
=0A=
www.oicr.on.ca=0A=
=0A=
This message and any attachments may contain confidential and/or privileged=
 information for the sole use of the intended recipient. Any review or dist=
ribution by anyone other than the person for whom it was originally intende=
d is strictly prohibited. If you have received this message in error, pleas=
e contact the sender and delete all copies. Opinions, conclusions or other =
information contained in this message may not be that of the organization.=
=0A=
=0A=
________________________________________=0A=
From: [email protected] [[email protected]]=0A=
Sent: November 22, 2014 5:42 AM=0A=
To: [email protected]=0A=
Subject: Re: nested roles are badly limited=0A=
=0A=
Hej John,=0A=
=0A=
Am 21.11.2014 um 22:32 schrieb John Macdonald:=0A=
> =3D=3D=3D=3D cat test1.pl=0A=
> package BRole;=0A=
> use Moose::Role;=0A=
>=0A=
> requires 'b';=0A=
>=0A=
> package ARole;=0A=
> use Moose::Role;=0A=
>=0A=
> has 'b' =3D> ( is =3D> 'ro', isa =3D> 'Scalar' );=0A=
>=0A=
> package main;=0A=
> use Moose;=0A=
> with 'ARole', 'BRole';=0A=
> =3D=3D=3D=3D=0A=
=0A=
just change it to this:=0A=
=0A=
package BRole;=0A=
use Moose::Role;=0A=
=0A=
requires 'b';=0A=
=0A=
package ARole;=0A=
use Moose::Role;=0A=
=0A=
has 'b' =3D> (is =3D> 'ro', isa =3D> 'Scalar');=0A=
=0A=
package main;=0A=
use Moose;=0A=
with 'ARole';=0A=
with 'BRole';=0A=
=0A=
And you're done.=0A=
=0A=
Kind regards=0A=
=0A=
--=0A=
Marco=0A=