Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Moo role subclassing

by arkturuz (Curate)
on Feb 24, 2016 at 17:05 UTC ( #1156037=note: print w/replies, xml ) Need Help??


in reply to Moo role subclassing

You cannot subclass a role, you must use it. From the documentation, this is how you use a role:
# bar gets imported, but not foo with('My::Role');

Replies are listed 'Best First'.
Re^2: Moo role subclassing
by Anonymous Monk on Feb 24, 2016 at 17:28 UTC

    Thank you for the response; I omitted the code where the roles are used, but it would look something like this:

    package App; use Moo; with 'BasicRole'; ... package AnotherApp; use Moo; with 'SpecialRole'; ...

    Since Moo does not allow roles to be extended, I am wondering if there is some magical, elegant way to implement what would essentially be subclasses of roles. I have some ugly, inelegant ideas for implementation, but was hoping that there might be something I'd missed.

      The whole point about roles is that they don't belong to an inheritance hierarchy and avoid thus the trouble sometimes associated with complex inheritance trees. Roles are composed into classes (and perhaps even, I do not know in the case of Moo, into object instances), but they don't inherit not can be subclassed.

      If you need inheritance and subclassing, use a class instead.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1156037]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2019-11-13 03:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (68 votes). Check out past polls.

    Notices?