[IronPython] Array Access Problem
jimhug at exchange.microsoft.com
Wed May 11 07:26:59 CEST 2005
Timothy Fitz wrote:
> On 5/10/05, Jim Hugunin <jimhug at exchange.microsoft.com> wrote:
> > >>> apt.X = 0
> > If value types were immutable this would throw. The exception
> > might give people enough information to get started tracking down
> > issue and modifying their code to work correctly.
> I want to say this should be equivelant to
> apt = Point(0, apt.Y)
> which would not break mutability issues. However this breaks with the
> current python trend (tuples could provide this functionality, but
Because of the way that value types work, there's no difference between
the results of
apt.X = 0 and apt = Point(0, apt.Y)
The big question is how important it is that both of the following are
apt.X = 0 and tmp = apt; 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
> To me, making apt.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
More information about the Ironpython-users