Keep It Simple, Stupid | |
PerlMonks |
Re: Use method/function signatures with Perlby Juerd (Abbot) |
on Dec 06, 2004 at 11:40 UTC ( [id://412624]=note: print w/replies, xml ) | Need Help?? |
I think the entire idea of rvalue accessor methods is flawed, now that we have the possibility to create lvalue ones. Since years ago, I have made programming much easier for myself by inventing some very simple rules:
Value validation used to be a good reason not to use lvalues. But there is Attribute::Property now. Not that I use it myself, though: sub foo : lvalue { shift->{foo} } (or sub foo : lvalue { $foo{+shift} } for inside-out objects) has proven to work very well, and value validation is something I don't do much (I expect people to RTFM).
This still throws values in @_ away. But as idiomatically this syntax is used without any parentheses at all, that is not a problem. Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
In Section
Meditations
|
|