Michael C said:
The compiler is going to need to know the return type anyway. I don't see
it much different from:
Parse(Something, ref x);
Why would you see it as that? The two are semantically different.
Anyway, yes the compiler already knows the return type, but it is capable fo
determing the return type from the method call alone. To overload on return
type would require more information than the method call alone can provide.
Overloading makes the language harder to learn, as does inheritance and
interfaces, we'd better leave those out too.
You realize, everyone uses this argument for everything. This is as
effective of a reason for insisting that the language must require case to
change for every letter of an identifier as it is for this.
As Steve Walker points out, its utility verse complexity. Inheritance and
interfaces offer significant utility with moderate complexity whereas return
type overloading provides minimal utliity with significant complexity.
But it can do it and it makes sense to the programmer for it to be double
all the way through.
It does? To me it doesn't in *ANY* way tell me that Parse() should be
returnign a double without knowing that the specific Calc method is tied to
the type of the return type. I don't think that is clear in any way. That is
like saying that I can tell from a baby what its grandfather looks like.
Sure, its possible, but its a shot in the dark unless you already know the
answer.
And,then, what does something like
this.Property = Calc(Parse(GetString()))
mean? The type is hidden and all three method calls are terribly ambigious
from the programmers point of view.
Let me ask you this, have you *ever* used an OO langauge that allows return
type overloading, especially one that determines the method to call
automatically?
I'm sure it can get complex but in any case it can't resolve the call it
should just say so. Programmers would know to specify the return type in
the necessary cases. Maybe something like double d =
Calc((double)Parse("15")): could be used.
Yet that is ambigious at best, what do you do when you end up needing code
you can't write because the compiler cannot resolve what you are doing?
And, more importantly, *WHY* is all this better than just DoubleFromString()
and IntFromSTring() ?