Timothy Fitz wrote: > On 5/10/05, Jim Hugunin <[EMAIL PROTECTED]> wrote: > > >>> apt[0].X = 0 > > If value types were immutable this would throw. The exception message > > might give people enough information to get started tracking down the > > issue and modifying their code to work correctly. > > I want to say this should be equivelant to > apt[0] = Point(0, apt[0].Y) > which would not break mutability issues. However this breaks with the > current python trend (tuples could provide this functionality, but > don't).
Because of the way that value types work, there's no difference between the results of apt[0].X = 0 and apt[0] = Point(0, apt[0].Y) The big question is how important it is that both of the following are equivalent. apt[0].X = 0 and tmp = apt[0]; tmp.X = 0 These two are different for value types in C# and VB. However, it's pretty weird to think about them being different in Python. It's easier for me to imagine supporting the version on the left if the version on the right will consistently throw claiming that tmp is immutable. This would still be confusing to people, but at least it would be very explicit. > To me, making apt[0].X = 0 require an explicitly new object is a > almost a showstopper. I'm not willing to go that far. It's a pretty rare case that you need to work with arrays of mutable value types with using CLS libraries. And the beauty of Python is that it's a great language for writing little helper routines to make the painful painless when needed. > Are there any other purely reference semantic > languages on the CLI? Or are we treading on new ground? That's a great question. I'm pretty sure that both J# and Jscript from MS have pure reference semantics and I'm sure there must be many other languages with this dilemma. I don't know what solutions other people have come up with. Does anyone else out there know? Has someone tried this in J# or Jscript to see how arrays of value types behave? Thanks - Jim _______________________________________________ users-ironpython.com mailing list users-ironpython.com@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com