[IronPython] Array Access Problem

Bob Ippolito bob at redivi.com
Fri May 6 00:15:02 CEST 2005

On May 5, 2005, at 3:02 PM, Sriram Krishnan wrote:

>> However, any time that I think about changing an invariant of the  
>> Python
> language I get rather nervous about the
>> ramifications...
> One ramification that I can instantly think of is looping over an  
> array of
> valuetypes. On more than one occasion, doing a foreach over an  
> array of
> structs in C# has bitten me
> People would break their heads trying to find the bug with this  
> piece of
> code (assuming that this change is implemented)
>  for point in apt:
>     point.X = point.X + 1 #do something with the point struct
> But frankly, I can't see how you can fix this.Valuetypes are going  
> to take
> some getting used to for Pythonistas

There are ways you *could* fix the issue:

(1) Don't have mutable value types, use a reference type that points  
to a value type (some kind of proxy)
(2) Make value types immutable (or at least the ones you grab from  


More information about the Ironpython-users mailing list