Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Moose roles

by EvanCarroll (Chaplain)
on Jan 13, 2010 at 16:38 UTC ( #817217=note: print w/replies, xml ) Need Help??

in reply to Moose roles

I think one of us is missing someone: those are attribute traits, they change the behavoir of the attribute (arguments to has). around is a method modifier, it gets called before its target method with a reference to the method. You could create an attribute trait that redefined the get and set subs installed in the meta giving you massively different behavoir, and that might have the effect of wrapping the accessors, but these are massively different functionalities. And the use of them should be dependent on the mental mapping and not the shortness. Either, it affects a method, or you want to change the behavoir of an attribute.

isa conversely specifies type, and without coerce => 1 that is little more (though sometimes the little matters) than saying what should throw an error.

I think you're trying to design an API using Moose terms without understanding that these reflect established (some bad) behaviors, and functionality. It is much more than a game to see how you want your code to look.

update: i noticed you also posted this same question to the mailing list without referencing pm or vise-versa.

Evan Carroll
The most respected person in the whole perl community.

Replies are listed 'Best First'.
Re^2: Moose roles
by dk (Chaplain) on Jan 13, 2010 at 18:31 UTC
    Yes, my apologies, I didn't reference this post in the list.

    Off the topic,.I don't understand why "has" doesn't allow shorter syntax - if I write "has x => (is=>rw, isa=>Int, ....)" two thousand times, why can't I declare a subtype or trait or whatever that would be accessible with "has x => mytype"? That's just not perlish, to write too much when you can avoid that :)

      Because has just says you want an attribute; rw means to generate getters/setter methods isa => x ({x != Any}) means you want it strictly typed (as much as you can get anyway)

      Evan Carroll
      The most respected person in the whole perl community.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://817217]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2017-06-25 02:22 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (564 votes). Check out past polls.