Alvin Bruney said:
I would like to know how this tard codes C# WITHOUT specifying return types
ROFL
Genius!!
Take this class, with return type overloading.
public class Class
{
public string Method(){};
public StringBuilder Method(){};
public Control Method(){};
public Button Method(){};
}
now, on this set of calls, waht are your results?
string stringResult = Method(); //clear, string Method(){} should be called
StringBuilder stringBuilderResult = Method(); // clear, StringBuilder
Method(){} should be called
object objectResult = Method(); // ambigious, any method could be called.
Control controlResult = Method(); // ambigious, should Control Method() or
Button Method() be called?
Method(); //ambigious, any method cound be called;
Your only option would be to change code calling to something akin to(syntax
invented):
object objectResult = string:Method(); //0k
object objectResult = Button:Method(); //0k
As I said, by specifying the return type, in the call not the declaration.
Thats where the complication comes in, it adds extra call syntax. Not to say
I'd be totally adverse to return type overloading if a simple, easy to
follow syntax existed, but only if it didn't result in significant addition
of complexity. Return type overloading beats GetWorkingSet64 imho, but the
additional complexity of the feature may not make it worth it.
Alvin Bruney said:
You already do have to SPECIFY RETURN TYPES.
Daniel O'Connell said:
It SHOULD be supported as its technically a DIFFERENT function signiture.
I think its stupid not to support this. Is there any valid reason
why
this
is not implemented?
I cant think of one.
Its pretty simple, it heavily complicates the language for very little
benifit. I don't care to have to specify return type on every call, doubt
you would either. Even with defaults it is a messy situation.
Do you have a suggestion as to how to implement it without causing a major
complexity increase?
True, and ILASM also, here's a sample (compile with ilasm).
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 1:0:5000:0
}
.assembly invaril
{
.hash algorithm 0x00008004
.ver 0:0:0:1
}
.class private Invariant
{
.method public specialname
instance void .ctor()
{
ret
}
.method public instance int32 Foo()
{
.locals init (int32 local0)
ldc.i4.1
ret //return 1
}
.method public instance int64 Foo()
{
.locals init (int64 local0)
ldc.i4.2
conv.i8
ret // return 2
}
}
.method public static void Execute()
{
.entrypoint
.locals init (class Invariant local0)
newobj instance void Invariant::.ctor()
stloc.0
ldloc.0
//Call int32::Foo()
callvirt instance int32 Invariant::Foo()
call void [mscorlib]System.Console::WriteLine(int32)
ldloc.0
// Call int64::Foo()
callvirt instance int64 Invariant::Foo()
call void [mscorlib]System.Console::WriteLine(int64)
ret
}
Willy.
"andrew lowe" <andrew dot lowe at geac dot com> wrote in message
Hi,
Why can I not overload on just the return type?
I believe Eiffel supports this