[IronPython] Questions for FAQ or User Guide
Richard Monson-Haefel
richard.mh at mac.com
Tue Apr 19 18:29:06 PDT 2005
It might be better if IronPython auto converted the list of real number
to an array in this case. If, that is, all the types in the list can be
widened to the correct type, or if the parameter is an array of
objects. That way you don't have to call an explicit method to set the
list to an array of Double types.
The reason, I think this is important, is that in Python developers
will avoid explicit typed of arrays in favor of loose typed lists
because its more Pythonic. Since interaction with general purpose
languages (strongly typed) will require more strict typing, the
interpreter or compiler should make that transformation (from List to
array of doubles) implicitly, or if it can't be done throw an
exception. Otherwise, you are forcing IronPython developers to adhere
to strict typing whenever they script interactions of objects defined
by general purpose languages like C#.
richard
On Apr 19, 2005, at 6:36 PM, Martin Maly wrote:
>
>
>>>> John A. Tenney Wrote:
>>>>
>>>> 1. I'd like to pass an array of 6 doubles to a method, but get an
> error message.
>>>> For example, the "myMethod" call below fails when it requires a
> double array.
>>>> array=[1, 2, 3.5, 4]
>>>> myObject.myMethod(array)
>
> If you create the array using the syntax above, you end up with object
> of type list.
> To create .Net array, you can do the following:
>
>>>> import System
>>>> array = System.Array.CreateInstance(System.Double, 5)
>>>> array[0]=1.3
>>>> array
> System.Double[](1.3, 0, 0, 0, 0)
>
> And call:
>
> myObject.MyMethod(array)
More information about the users-ironpython.com
mailing list