There is a comment in the source code that offers a little (but not much) more explanation:

# this code is broken and should never have been added. i probably # won't delete it, but it is definitely not up-to-date with respect to # other features, and never will be. # # runtime role application is fundamentally broken. if you really # need it, write it yourself, but consider applying the roles before # you create an instance.

There are some obvious problems with run-time role application. For example, if you have an existing object $o, and you then apply this role to it at runtime:

package Example::Role { use Moose::Role; has thingy => (is => 'ro', isa => 'Str', required => 1); }

Then what is the value of $o->thingy? If you consider a role to be a contract that an object is obliged to implement, then the runtime application of Example::Role to $o is breaking that contract.

For runtime role application to an object, I'd use Moose::Util's ensure_all_roles function. It still suffers from the same problems but at least it doesn't have this annoying warning message. :-)

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

In reply to Re: Why is MooseX::Traits::apply_traits() deprecated? by tobyink
in thread Why is MooseX::Traits::apply_traits() deprecated? by stevenl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.