Jun 11, 2012

Perl Core Syntax Wishlist: Role Support

I want to see Role's added, even PHP got Traits before Perl. It doesn't have to be a huge thing, in fact all I want is the composition aspect. Let me do this: I don't really want or need anything else right now, just that would be fine. We should have interfaces too, but they aren't really required just to support Role's. We should probably have some sugar like I did for class (e.g. role keyword. and some of the same modules/pragmas loaded for this too)

6 comments:

  1. "PHP got Traits before Perl"

    Come on :) Is Moose released before PHP 5.4.0?

    ReplyDelete
  2. Just humour me a moment...

    What about your example wouldn't work by:

    package MyRole {
    sub foo { return 'test' }
    }
    package MyClass {
    use base qw( MyRole );
    ...
    }

    MyClass->new->foo;

    ?

    ReplyDelete
  3. @harbud like all of my wishlist series, CPAN doesn't cut it. Fortunately this should be a feature of p5p MOP. @LeoNerd when I say that's all I want I should probably have clarified that It still has to do it via composition not inheritance, meaning application of multiple roles could/should behave differently than multiple inheritance. What I was trying to say is I'd be ok getting it without a MOP

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Well, if a MOP would be nice to have anyway, maybe you'd be interested in the #p5-mop hackathon in Norway in August. :)

    http://act.yapc.eu/mtmh2012/

    ReplyDelete
  6. I'd love to go, in fact I'd love to go and stay, unfortunately I don't see it as being financially feasible at this time.

    ReplyDelete

No trolling, profanity, or flame wars :: My Blog, my rules! No crying or arguing about them.