On Mon, 07 Mar 2011, Chris Prather wrote: > > In my opinion you're moving from dangerous to useless at best. I feel > that the *semantics* of this syntax are confusing. They confuse method > dispatch with assignment*. I disagree. The semantics of setting attributes/properties are the same as assignment: * setting the attribute multiple times to the same value is not supposed to have any additional effect beyond what the first assignment did * the attribute is supposed to return the value it was last set to Attribute setters/getters are *not* supposed to be generic methods; they are syntactic sugar for assigning and querying values. And many languages (VB, C#, JavaScript, of the top of my head) all use assignment syntax for property manipulation. The fact that under the hood they all perform a method dispatch is an implementation detail that doesn't have to be exposed to the user. > To me it's a dangerously short step from > $obj->attr = $x; to $obj->{attr} = $x; where you drop the > encapsulation entirely. This is simply not correct. You cannot know what the assignment is going to do, as $obj may be tied (implementation detail, you don't have to know), so everything is as encapsulated as the class author wants. > Suggesting that encapsulation is a bad thing, or even an undesirable > thing is the "horrible idea". Especially for the beginners that the > advantages of a $obj->attr = $x syntax would primarily benefit. Nobody suggested that encapsulation is a bad thing, so I call strawman here. Cheers, -JanThread Previous | Thread Next