XP is just a number | |
PerlMonks |
Re^2: Is ": lvalue" attribute usefull or something to avoid?by tobyink (Canon) |
on Feb 12, 2014 at 12:01 UTC ( [id://1074615]=note: print w/replies, xml ) | Need Help?? |
It is possible to validate the values, it's just traditionally a pain in the arse, because it involves using something like Variable::Magic or returning a tied scalar. I wrote LV to try to get around these issues, and it does indeed make writing lvalue subs pretty friendly. The primary drawback becomes speed - none of the implementations are as fast as a more traditionally written accessor.
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
In Section
Seekers of Perl Wisdom
|
|