It would be great to be able to handle ref and out parameters the way that IronPython does. See: http://ironpython.codeplex.com/wikipage?title=FAQ&referringTitle=Home How can I call a method with ref, out, and params parameters?
I have added a patch to fix this: https://sourceforge.net/tracker/?func=detail&aid=3117417&group_id=162464&atid=823893
Urs has provided an interesting approach to the out parameter handling which I'll play around with.
I was actually more interested in the ref parameter creation/in place-modification as demonstrated at http://www.voidspace.org.uk/ironpython/dark-corners.shtml:
"Similar to out parameters are ref parameters. These need to be initialised with a value, so they can't just be returned as additional values. Instead we create a reference using clr.Reference."
From C#:
int value = 6;
SomeMethod(ref value);
From IronPython:
import clr
reference = clr.Reference(6) self.SomeMethod(reference)
updated_value = reference.Value
Log in to post a comment.
I have added a patch to fix this:
https://sourceforge.net/tracker/?func=detail&aid=3117417&group_id=162464&atid=823893
Urs has provided an interesting approach to the out parameter handling which I'll play around with.
I was actually more interested in the ref parameter creation/in place-modification as demonstrated at http://www.voidspace.org.uk/ironpython/dark-corners.shtml:
"Similar to out parameters are ref parameters. These need to be initialised with a value, so they can't just be returned as additional values. Instead we create a reference using clr.Reference."
From C#:
int value = 6;
SomeMethod(ref value);
From IronPython:
import clr
reference = clr.Reference(6)
self.SomeMethod(reference)
updated_value = reference.Value