* Chris Prather <chris@prather.org> [2011-03-07T15:21:44] > On Sun, Mar 6, 2011 at 9:34 PM, Father Chrysostomos <sprout@cpan.org> wrote: > > If we do add object attributes to Perl, it would be very nice if we could > > use ‘$obj->attr = $foo’ syntax, instead of $obj->attr($foo), which is > > currently widely used mainly because the former is so hard to do (that can > > change, of course). > > > > It's my (not-so-humble) opinion this is a horrible idea. It violates > encapsulation and confuses the behavior with state in a way that will > only lead to *more* confusion down the line. He didn't say that it would have to be lvalue subs. Look at how Ruby does this: you provide an "attr=" method that is called on assignment, so you are not violating encapsulation or confusing behavior with state. It's sugar for a normal method call, which can have any behavior you want and mutates whatever state system it wants however it wants. I'm not saying that I want ->attr=$x, only that you are arguing against something that needn't be true. -- rjbsThread Previous | Thread Next