If I understand you, the (only) reason against having lvalue accessors is because it can't run the validation, coersion, triggers, etc. on a SET.

Meanwhile, you say none of that is necessary on private data anyway.

But, the representation of the class is opaque. I can't get at the slot without going through the MOP or inline functions generated by the MOP.

Does the average class need to have complete freedom to separate instantiation representation from the class? That's akin to the 'tie' feature in classic Perl 5, and agree that this is better served using abstract interfaces. I won't be changing the "bits" suddenly to a different implementation. Hmm, or will I? In Perl 5.xx+ maybe an efficient XS-based slot mechanism will be added to some platforms, and my existing classes and most of CPAN and all the Catalyst stuff should just work and suddenly work faster! So, maybe I want to keep my options open just now.

Now roles on the other hand can be added to any kind of class, and can't assume the storage layer in use by whatever class it winds up in. So it should be more abstract, unless it's app-specific and knows something about where it's going.

So, maybe you and I would both like a lvalue option. Declare my private instance data with some keyword or something that makes it generate an lvalue accessor for combined get/set usage, with no init-arg, type check, etc.

Another idea would be a Moose implementation layer that guaranteed a certain naming convention among its use of hash keys, and was known to be a blessed hash. Then you could add your own instance data among the $self->{keys} in the classic manner. You would define that you wanted that implementation metaclass (whatever it's properly called in Moose) when you created that class.


In reply to Re^2: Some thoughts on Moose Attributes by John M. Dlugosz
in thread Some thoughts on Moose Attributes by John M. Dlugosz

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.