Updated July 2015 for coherence and to note related SO qa.

Hi Dean,

First, thanks for exploring Perl 6. I hope it's fun. :)

If you use the `is rw` trait on an attribute, you're asking the compiler to automatically generate a setter for you, a method with the same name as the attribute. This method will be a lvalue routine. And the setter method syntax (eg `$i.lb = 6`) will work.

You create a custom setter method by explicitly declaring a method with the same name as the attribute. You should mark it `is rw` and return a Proxy object with suitable FETCH (read) and STORE (write) routines.

However, please know that, in addition to eluding documentation, Proxies may lead you to encounter bugs, not yet implemented stuff, missing sugar, etc.

(In the Perl 6 world, unlike in the Perl 5 world, the current implementation and especially documentation state of things is often LTA. Both the software and doc (activity) continue to improve but they've still got a long, long way to go.)


In reply to Re: [perl6] Complex Attribute Validation and/or Triggers by raiph
in thread [perl6] Complex Attribute Validation and/or Triggers by duelafn

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.