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