S
Steve Walker
Michael C said:Overloading makes the language harder to learn, as does inheritance and
interfaces, we'd better leave those out too.![]()
It's a trade-off of utility against complexity. I'd be on the "not worth
it" side of the debate. I can't see that it would be a useful enough
feature to be worthwhile, and I think that if C# had it, and I found
myself using it, I'd immediately suspect that I needed to refactor the
code.
If the different versions of the method were semantically identical, you
would just be hiding a cast or conversion. Assuming simple types, I can
only see that you might want to encapsulate that if it were doing
something specific to the context of the class. If that were the case
you could create non-intuitive anomalies; if int Foo(){} and float
Foo(){} were overloads with different return types, and int Foo(){} did
something other than cast a float to an int, you may end up with
(int)Foo() != (int)(float)Foo()
If the methods returned instances of classes of my own making, I'd look
at returning a supertype.
If they were not semantically identical, they should have had different
names.