[IronPython] 'out' parameters

Martin Maly martmaly at exchange.microsoft.com
Wed May 11 17:01:08 CEST 2005


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;
        }
    }
}

Python:
i = C.M()
print i

(10, 20, 30, 40)

If there is just one output of the function (i.e. void function with one
out parameter), the value comes back as a function return value.

Martin

-----Original Message-----
From: users-ironpython.com-bounces at lists.ironpython.com
[mailto:users-ironpython.com-bounces at lists.ironpython.com] On Behalf Of
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'
variable?

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 result 
would be modified, right?  But it needs to be changed within the
function 
CheckCooperativeLevel, and I need to get the result back!

Thanks,

--Nick




More information about the Ironpython-users mailing list