Interesting...

From a DOTNET-CLR post: An interesting feature of MSIL that is not currently exposed in any of the languages -- "method overload based on return type only." Very interesting!

4 Comments

  • That is interesting, and something which is sorely missing from current languages. I am not aware of the logic behind the decision to not implement this in (for example) C# - does anyone have any idea why this is?

  • No idea why it's not included. It actually makes sense that it would be very easy to do. In .NET, the compiler knows (at compile time) what kind of variable you're putting the result in. It could easily call the correct overload based on return type.



    Things would get trickier if the return type is never used... i.e:



    public string foo() {...}

    public int foo() {...}



    And the function is simply called as:



    foo()



    Which one to call?

  • This is weird because on the way to work I was reading Essential .Net by Don Box and he mentions (sort of in passing) that the CLR supports method overloading based on return types, but that it is merely prohibited by the CLS.

  • This is weird because on the way to work I was reading Essential .Net by Don Box and he mentions (sort of in passing) that the CLR supports method overloading based on return types, but that it is merely prohibited by the CLS.

Comments have been disabled for this content.