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. Martin -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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: http://lists.ironpython.com/htdig.cgi/users-ironpython.com/2006-May/002265.html http://lists.ironpython.com/htdig.cgi/users-ironpython.com/2005-May/000651.html etc. and http://channel9.msdn.com/wiki/default.aspx/IronPython.ValueTypes 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 VertextDeclaration. 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, Element(a[i].UnchangedValues, n)). 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 [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
