Stories
Slash Boxes
Comments
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • by kag (4257) on 2006.08.11 23:18 (#49317) Journal
    I decided to take the Moose out for a test drive, and ran into:

    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?
    • Yes, lvalue accessors are pretty useless in the real world. That's because you don't get a chance to intercept the value that's being assigned to. You can't (say) step in and clone something before it's assigned.

      -Dom

      • Unless, of course, you return a tied value…

        Somehow, it feels like this discussion has already happened a couple times before…

        • Very true, but it does start to feel like a lot of work that could be sidestepped by using a mnore traditional approach.

          -Dom

    • 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