in reply to [perl6] Complex Attribute Validation and/or Triggers
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.)
»ö« . o O ( "the celebrity tell-all of the Perl-6 cult?" )
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: [perl6] Complex Attribute Validation and/or Triggers
by duelafn (Parson) on Mar 09, 2015 at 13:26 UTC | |
by raiph (Deacon) on Mar 11, 2015 at 03:48 UTC |