Martin.Maly at microsoft.com
Wed Mar 7 21:55:19 CET 2007
New value types cannot be defined in IronPython, you can only instantiate and use existing ones.
The a[i].x = n does throw and it is not possible to achieve this without replacing the whole array element. Essentially, for IronPython, value types are immutable and they can only be copied as a whole.
Alternative to what you are doing with a.SetItem, could be (but it ultimately ends up doing pretty much the same operation):
a[i] = new MyValueType(a[i].UnchangedValues, n)
Partial class implementation cross language is not possible in the "partial class" C# sense. However since you can inherit from .NET class in IronPython, you could perhaps achieve what you need through inheritance.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Aaron Leiby
Sent: Wednesday, March 07, 2007 11:28 AM
To: Discussion of IronPython
Subject: [IronPython] ValueTypes
Just started using IronPython - playing with XNA.
Digging up a couple old threads:
Can new value types (i.e. structs) be declared in IronPython? If so, what
defines the data layout. Like for instance if I want to create a new
What's the current status of a[i].x = n? Well, the current status is it
throws an exception warning you that it cannot be modified. What's the
proper way to update elements in an array? Is it possible to do without
replacing the entire element? I'm currently using a.SetItem(i,
For now, I've moved my vertex declarations back into C#, and since I care
about performance in the update loop, I should probably push that back into
C# as well, avoiding these issues entirely.
There's no way to partially implement a class across the language
boundaries, is there? (Since they would need to span assemblies?) Anything
that needs to get pushed back to C# for performance reasons will need to
have any required member data pass along, correct?
Thanks for bearing with these newb questions.
users mailing list
users at lists.ironpython.com
More information about the Ironpython-users