Is there something wrong with Perl 5's lvalue attribute? As far as I can tell, it produces rather functional lvalue accessors:
I know that user-defined functions with the lvalue attribute, in general, will give wrong results in the debugger, but that's only a problem for those weenies who use the debugger ;-) (Plus, there are good ways around this.)package Foo; sub foo : lvalue { my $self = shift; warn "Only first argument to method foo is used" if @_ > 1; $self->{ foo } = shift if @_; $self->{ foo }; } my $x = bless +{}, 'Foo'; $x->foo = 3; print $x->foo, "\n"; $x->foo++; print $x->foo, "\n"; $x->foo += 6; print $x->foo, "\n"; __END__ 3 4 10
the lowliest monk
In reply to Re^6: Tim O'Reilly on Perl
by tlm
in thread Tim O'Reilly on Perl
by fauria
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |