[IronPython] Re: 'out' parameters

Nick Jacobson nicksjacobson at hotmail.com
Wed May 11 20:23:21 CEST 2005

Jim and Martin,

Thanks for the reply, and it makes sense :)

Unfortunately, a call to CheckCooperativeLevel() returns True, not a tuple.  
This is probably because there are two overloaded CheckCooperativeLevel 
methods in the Device class in the Microsoft.DirectX.Direct3D namespace.  
They are:

public bool CheckCooperativeLevel();
public bool CheckCooperativeLevel(out int result);

IronPython has no way of knowing I want the second and not the first.


Jim wrote:

<< Martin's response is right, but I'm afraid that the best way to use
these return values might not be obvious to everyone.  Python's tuple
packing and unpacking operations are often used for multiple return
values in standard Python libraries and IronPython should feel the same
way.  Here's how these calls should look in IronPython:

  ret, result = CheckCooperativeLevel()
  m, i, j, k = C.M()

And for completeness, I'll add that 'ref' parameters are both passed to
the function and returned as an additional return value.

-Jim >>

Martin Maly wrote:
>The return value and output parameters (if they are in total more than
>one) are returned as tuple:
>namespace N {
>     public class C {
>         public static int M(out int i, out int j, out int k) {
>             i = 20;
>             j = 30;
>             k = 40;
>             return 10;
>         }
>     }
>i = C.M()
>print i
>(10, 20, 30, 40)
>If there is just one output of the function (i.e. void function with
>out parameter), the value comes back as a function return value.
>-----Original Message-----
>From: users-ironpython.com-bounces at lists.ironpython.com
>[mailto:users-ironpython.com-bounces at lists.ironpython.com] On Behalf
>Nick Jacobson
>Sent: Tuesday, May 10, 2005 11:08 PM
>To: users-ironpython.com at lists.ironpython.com
>Subject: [IronPython] 'out' parameters
>How will IronPython deal with functions that, in C#, use an 'out'
>For example, in Microsoft.DirectX.Direct3D, this function exists:
>public bool CheckCooperativeLevel(out int result);
>If I call this from IronPython, there's no way that the value of
>would be modified, right?  But it needs to be changed within the
>CheckCooperativeLevel, and I need to get the result back!
>users-ironpython.com mailing list
>users-ironpython.com at lists.ironpython.com

Is your PC infected? Get a FREE online computer virus scan from McAfee® 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

More information about the Ironpython-users mailing list