in reply to Using perl 6 roles in perl 5

Why not take a look at the four different implementations of roles that are out there right now and see if one is right for you.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Replies are listed 'Best First'.
Re^2: Using perl 6 roles in perl 5
by clinton (Priest) on Jan 18, 2006 at 15:22 UTC
    I should have looked - that was dumb. But looking at the code, they seem to be using a similar approach.

    Which is good.

    It just seems annoying to have to require a module whose purpose, in my code, I am accomplishing in a few lines.

    It's the old roll-your-own scenario. I'll insist on using my own code because I'm-only-using-it-in-this-one-place and probably 6 months down the line, I'll rip it out and replace it with one concise nicely written and document module installed from CPAN.

    But how else do we ever learn?

    Now where is my home-rolled templating system? No, not those ones, the other one.

      But how else do we ever learn?

      By improving on the current systems, not by rewriting them. Take a look at the code for Perl6::Roles. For the most part, it's just syntactic sugar. Class::Trait is more involved, but it's still just sugar, at its heart.

      If there's a feature you want or a performance benchmark you feel you need to hit, write a failing test and give it to the author. That way, everyone benefits from what you're trying to do.


      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
        You're right.

        I now need to write another class which inherits the caching but not the database interface functionality from my base classes, and suddenly roles seem like a really really good idea.

        And using a contained module seems like a much better idea than the few lines of code which did the job just 2 hours ago.

        By improving on the current systems, not by rewriting them.
        Out of interest, why did you rewrite Perl6::Role when Class::Role already existed?