[IronPython] Method overload
dinov at exchange.microsoft.com
Mon Jan 9 10:05:17 PST 2006
The  syntax is for generic types - not for method overloads.
Just for more info on method overloads in general - for those that have multiple method bindings we'll hit our ReflectedMethodBase.TryCall implementation. That will evaluate the conversions for each argument and methods and will ultimately dispatch to the method that has better conversions. If two methods have "mixed" conversions [(one "good", one "bad") / (one "bad", one "good") ] then we'll just end up picking the first method. We also take into account various other factors such as if we're turning the first argument into a this pointer and we'll have non-params arguments over params arguments. It's also worth pointing out this whole process is slow....
For optimized calls (currently just core built-in CLR types and types the IronPython runtime exposes) we'll generate fast-paths for methods that don't have multiple bindings. Our definition of multiple bindings is methods that have 1 overload for each number of parameters (eg 1 overload that takes 1 parameter, 1 overload that takes 2 parameters, etc...) and methods that only have 1 params method. If the method falls outside of this it's not optimized. That's an implementation detail that probably no one needs to know, but I'm just throwing it out there for completeness. We're also looking at improving our optimizer so it can optimize more methods this way (and there probably deserves some thought about how we can allow user-methods to be optimized when hosting IronPython as well).
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of J. Merrill
Sent: Monday, January 09, 2006 9:32 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Method overload
Isn't there a syntax (using ) by which you can tell IP explicitly which one it should use? I was expecting you to say what you did, but to add info about that as well.
At 12:48 AM 1/8/2006, Martin Maly wrote
Yes, it will work on .NET. IronPython will try to find the best fit among the overloads based on types of arguments that you pass to the method call. There may be cases when IronPython may not choose the right method & and we want to hear about those cases so we can fix them.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Fabio
Sent: Saturday, January 07, 2006 4:42 PM
Subject: [IronPython] Method overload
I'm studing IronPython and I liked very much!
But I have one question.
In .Net Framework, several classes has method overload. In my study, Python does not support method overload, and when we define methods with the same name, they are redefined then only the last is used.
How IronPython handle this? By example, the method "System.Console.Write()" has 18 overloads! This will work in .Net?
J. Merrill / Analytical Software Corp
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the users