NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
lvalue accessors (Score:1)
has 'count' => (is=>'rw', isa=>'Int');
$thing->count++; # fails!
$thing->count($thing->count + 1); # ugly!
Are lvalue accessors considered harmful, or would this make a good Moose::Policy?
Re:lvalue accessors (Score:1)
Well to be honest, I am not sure what lead you to think that would work in the first place ;)
I will admit that
$thing->count($thing->count + 1)is ugly, but lvalue accessors are really problematic in a lot of ways.It has been suggested before that certain types could have additional accessors, so that this
$thing->count($thing->count + 1)could become$thing->count_increment()or some such. But of course this is not always desired, so probably wouldnt be a good thing to force on all situations. But really, at this point though, I have not seen a good proposal for how this feature would look and work, so it remains just an idea. Until then, you could alway write your own increment_count method.-- Stevan
Reply to This
Parent