Moo uses code like this to add an attribute to a class:

has taste => (is => 'ro',);

That's too much typing for lazy people. So applying the standard rules: 'parentheses don't really do anything so you can delete them', 'fat commas are really just commas', leads to this:

has 'taste', 'is', 'ro';

Well there's no point typing in that comma separated list is there? Why not use qw? This works:

has qw/weight is rw default 100/;

MooseX::MungeHas allows has to haz defaults:

use MooseX::MungeHas 'is_rw'; has foo => ();

Using the 'standard rules' this becomes:

has 'foo'; # works okay

But then to create a read-only attribute, it needs to be specified:

 has roattr => (is => 'ro');

Is there a way to make hasro and hasrw functions to add attributes? Maybe there's a module that does this and i just haven't found it yet?

hasrw 'weight'; # read-write hasro 'roattr'; # read-only

Then if somebody was verrry lazy, they can easily define their classes without having to type a bunch of parentheses, fat commas, and typing in 'is' over and over again. Obviously this wouldn't be suitable for all uses.


In reply to Extra-lazy object oriented programming by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.