|Keep It Simple, Stupid|
$foo->bar = 14;by Juerd (Abbot)
|on Dec 29, 2002 at 19:25 UTC||Need Help??|
Traditionally, object properties in Perl are retrieved and set either through methods or by using the object as the reference it is.
To automate the creation of accessor methods, I don't use a module, but a simple closure creating loop like this one:
In #perlhelp (efnet), xmath pointed out that methods can be used as lvalues (with the lvalue attribute). It appears attributes work on anonymous subs. That knowledge combined leads to something like:
So that means:
Before I'm going to change my coding style, I'd like to know what the community thinks of it. The lvalue attribute is experimental.
Note that I know this doesn't check the new values. Neither did my old code - I don't really care :) And no, I don't like using the hash reference for my external API.
So, what do you think?