(OK, the subject sucked, but I tried :)

From S14:

  You can, however, say
      $fido does Sentry;
      $fido does Tricks;
      $fido does TailChasing;
      $fido does Scratch;
  <snip>
  Unlike the compile-time role composition, each of these layers
  on a new mixin with a new level of inheritance, creating a new 
  anonymous class for dear old Fido, so that a .chase method from 
  TailChasing hides a .chase method from Sentry.

Recently I reported a bug in Moose's runtime role application:

  http://rt.cpan.org/Public/Bug/Display.html?id=43904

The problem was very hard to track down because I was effectively doing 
something like this:

  $object->meta->apply('Some::Role') while 1;

(The reality is that we had a singleton with a role applied to it multiple 
times).

Eventually, the code broke and threw a bunch of weird "recursive inheritance" 
warnings due to multiple anonymous classes being applied to the object.  This 
was *real fun* to debug, but I can imagine a scenario for this being natural:

Your REST interface returns XML, but sometimes someone wants YAML.  So you have:

  $resultset does Role::Serializable::XML

But sometimes:

  $resultset does Role::Serializable::YAML

Since you cache resultsets if they've not changed, you could easily have the 
XML and YAML roles getting reapplied at runtime multiple times.  

I don't see anything in the spec addressing this.  Aside from "don't do that", 
is this something which can be addressed in perl instead of Perl?

Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

Reply via email to