I don't know about all programming languages, but it's clear that usually the possibility of overloading a method taking into consideration its return type (assuming its arguments are the same number and type) is not supported.
I mean something like this:
int method1 (int num)
{
}
long method1 (int num)
{
}
It's not that it's a big issue for programming but on some occasions I would have welcome it.
Obviously there would be no way for those languages to support that without a way to differentiate what method is being called, but the syntax for that can be as simple as something like [int] method1(num) or [long] method1(num) that way the compiler would know which would be the one that would be called.
I don't know about how compilers work but that doesn't look to be that difficult to do, so I wonder why something like that isn't usually implemented.
Which are the reasons why something like that is not supported?
Foo
andBar
. – user44761 Apr 28 '16 at 21:18