I've been wondering for a couple of years about why overloading
stops at the argument sig in almost all languages, but so far I
have not seen a good reason why this must be so.
From what I've read so far, the reason why full overloading is
not being done, is because it is not being done. Other than that,
I don't have an answer as to why it is not being done because
clearly it can be done, and the compiler certainly has the means
to do it already, otherwise it could not err when you assign a
function return type to the wrong type on the LHS, ie, it most
certainly is able to determine what the full signature is at some
point.
So does anyone really know why it is not being done? The "it's
too complicated" argument seems weak to me since the compiler
already has to check for both matching argument sig as well as
the return type, and it already does overloading on the argument
sig. I figure "it's too complicated" only because the compiler
was initially designed without taking full signature overloading
into account from the very start, otherwise it would be not much
more complicated than the regular overloading that we have now.
The argument that the compiler will get too confused seems a bit
weak as well, since the compiler can already get confused with
argument sig overloading, and there are certainly methods of
working this out, otherwise function overloading would not work
as it is now. At the end of the day, if the compiler cannot
figure it out, then it errs, just as it does now when it cannot
figure it out. There's already an incalculable number of ways a
programmer can mess up a valid compile, so adding one more
possible way to the already massive pile cannot be used as a
reason why it should not be done.
I could argue that overloading only on function sig is too
complicated and not worth it, but we have it, and it is useful to
at least some or most people, so why did we stop at the argument
sig and not go all the way? Is there a theoretical reason why we
should stop, are their use cases that have shown that it fails to
help the programmer or makes programming more difficult?
--rt