sweetening moose

even if moose is nice and allows to prune a lot of code, it can still be seen as cryptic. take the following example, and imagine that you have a lot more attributes to declare:

the first thing that can be done is using moose builtin types instead of their name, with moosex::types::moose. this allows to remove the quotes around the types:

but that's still a bit mouthful. enters moosex::has::sugar, for a nicer code:

your code is now more readable - yet some other modules that i'll now use in my dists...


  1. I use qw to declare lot of moose things:

    package Human;
    use Moose;

    has Firstname => qw< isa Str is rw required 1 lazy_build 1 > ;


  2. @marc: not recommended by moose folks... and it's still mouthfull.

  3. I would say Uglying Moose and making things more Complex.

    In the first Version you just have simple key=>value that everybode knews.

    The second version has absolutly no benefit over the first.

    And in the third version you left key=>value assignment that can produce more confusion then solve confusion.

  4. @sidburn22: i guess that's in the eye of the beholder. i happen to like it, and find it really easier to read, which is why i shared it here. but you're in no way forced to use it...