[IronPython] Choosing the right overload
J. Merrill
jvm_cop at spamcop.net
Fri Jun 16 17:38:35 CEST 2006
At 06:25 AM 6/16/2006, Jonathan Jacobs wrote (in part)
>Hi,
>
>I'm wondering how to call a specific overload, more specifically one that in
>C# would take an out parameter but in IronPython does/can not.
>
>Here are the available overloads:
>
> >>> print Direct3D.Mesh.FromFile.__doc__
>[snip]
>static (Mesh, array_ExtendedMaterial) FromFile(str filename, MeshFlags
>options, Device device)
>static Mesh FromFile(str filename, MeshFlags options, Device device)
>[snip]
>
>I want to call:
>
>static (Mesh, array_ExtendedMaterial) FromFile(str filename, MeshFlags
>options, Device device)
>
>I've tried using __overloads__:
>
> >>> print Direct3D.Mesh.FromFile.__overloads__[(str, Direct3D.MeshFlags,
>Direct3D.Device)].__doc__
>static Mesh FromFile(str filename, MeshFlags options, Device device)
>
>I'm going to assume that I'd need some way to specify the return type, which
>also makes me wonder how you'd specify an object of type array_ExtendedMaterial?
Something would be wrong if __overloads__ is keyed only by the input type(s). It has to include the out parameters, in the position that they're defined by C#.
>So, is there a way I can do this without resorting to writing a C# helper
>function?
If you know where the "out" parameter goes in the parameter list (e.g. at the end) you could specify a tuple that includes it in the right spot. Martin has shown you how to define the array.
I don't know if C# allows overloads that are identical except for out-ness -- can you have both
int Foo(string x, out int blah)
and int Foo(string x, int blah)
???
J. Merrill / Analytical Software Corp
More information about the Ironpython-users
mailing list