Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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.
www.evancarroll.com


Comment on Re: Moose roles
Download Code
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.
      www.evancarroll.com

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://817217]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-09-20 06:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (155 votes), past polls