In the example for overload resolution this example was given:
M( int x, int y); M( string x, sting y);
Then it was explained how the resoulution worked. It was said that the very first thing to be checked is if all the names are in the method's parameters. I found it strange that it does not do a simple argument type check before matching names in the paramters
list. If you know you are getting two integers in the call, you know that the overload must accept at least two integers.
So if you have:
M( int x = 0, int y = 22, int z = 10, string text = "no"); M( string x = "20", sting y = "90", int data = 200 );
Suppose I call M( y = 300, x = 200); The complier knows that I am giving the M two ints. If I now was to "check if all the names are there", that would yield both Ms. On the other hand by simply counting the number of parameters of each type in the call and
comparing the counts with the overloads you will find the right one. There is only one M that accepts two ints or more. This will enables you to discard all overloads that does not have any chance at matching the signature, and focus on the ones that does
in the later steps that involves name matching etc.
I may just be plain wrong, and this may be inefficent for reasons I don't know. Maybe this even happens behind the scenes and just wasn't metioned in the interview. Just my thoughts after watching
1. The powershell window won't resize like a normal window. The stone-aged buffer-aproach is a bug in 2008. 2. If I pipe some long output to the more function, and want to see the output line by line,, it clutters the output with it's own promt for every line. That would have been a bug 50 years ago
The best would be if these bugs could be worked around, or that I simply har missed something to make these things work
Expert to Expert - Joe Duffy: Perspectives on Concurrent Programming and Parallelism
Feb 17, 2009 at 12:59 PMInside C# 4.0: dynamic typing, optional parameters, covariance and contravariance
Dec 05, 2008 at 2:55 AMM( int x, int y);
M( string x, sting y);
Then it was explained how the resoulution worked. It was said that the very first thing to be checked is if all the names are in the method's parameters. I found it strange that it does not do a simple argument type check before matching names in the paramters list. If you know you are getting two integers in the call, you know that the overload must accept at least two integers.
So if you have:
M( int x = 0, int y = 22, int z = 10, string text = "no");
M( string x = "20", sting y = "90", int data = 200 );
Suppose I call M( y = 300, x = 200); The complier knows that I am giving the M two ints. If I now was to "check if all the names are there", that would yield both Ms. On the other hand by simply counting the number of parameters of each type in the call and comparing the counts with the overloads you will find the right one. There is only one M that accepts two ints or more. This will enables you to discard all overloads that does not have any chance at matching the signature, and focus on the ones that does in the later steps that involves name matching etc.
I may just be plain wrong, and this may be inefficent for reasons I don't know. Maybe this even happens behind the scenes and just wasn't metioned in the interview. Just my thoughts after watching
Great stuff btw
Expert to Expert: Erik Meijer and Jeffrey Snover - Inside PowerShell
Dec 04, 2008 at 4:56 PM1. The powershell window won't resize like a normal window. The stone-aged buffer-aproach is a bug in 2008.
2. If I pipe some long output to the more function, and want to see the output line by line,, it clutters the output with it's own promt for every line. That would have been a bug 50 years ago
The best would be if these bugs could be worked around, or that I simply har missed something to make these things work
Expert to Expert: Erik Meijer and Jeffrey Snover - Inside PowerShell
Dec 04, 2008 at 2:14 AM