in reply to Single accessor/mutator idiom in Perl5, Perl6 and Python

As one who has generally done separate functions so I could guarantee to allow only one or the other if I wanted to, this topic makes me wonder about lvalue subs. Why not just make the accessor/mutator be an lvalue sub?

--traveler

  • Comment on Re: Single accessor/mutator idiom in Perl5, Perl6 and Python

Replies are listed 'Best First'.
Re^2: Single accessor/mutator idiom in Perl5, Perl6 and Python
by adrianh (Chancellor) on Aug 19, 2003 at 22:04 UTC

    You can do it that way, but see lvalue considered harmful... for some reasons why it may be a bad idea.

    Jeurd's Attribute::Property is worth investigating if you like the lvalue style. It resolves some of the problems of lvalue subs at the expense of some tied objects behind the scenes.