Groups | Blog | Home
all groups > dotnet clr > july 2004 >

dotnet clr : Will 2.0 of the clr have support for covariant returns?


Hasani (remove nospam from address)
7/19/2004 9:38:31 PM
Will 2.0 or some other future version of the clr have support for covariant
returns?

Mickey Williams [C# MVP]
7/20/2004 10:33:55 AM

[quoted text, click to view]

Covariance works in Eiffel under CLR 1.1 today, so it's not impossible to
implement, merely difficult -- although I'm fairly sure that this is
strictly an Eiffel language feature that the compiler manages for you, just
like their support for generics and MI. The generated IL is some complex
kungfu.

--
Mickey Williams
Author, "Visual C# .NET Core Ref", MS Press
www.neudesic.com
www.servergeek.com


Daniel O'Connell [C# MVP]
7/20/2004 5:15:17 PM

"Mickey Williams [C# MVP]" <my first name at servergeek dot com> wrote in
message news:OujQh8nbEHA.1644@tk2msftngp13.phx.gbl...
[quoted text, click to view]
The clr itself *doesn't* support covariance. One of the requirements of
method overloads is that the signature matches exactly. IIRC, most compilers
that simulate covariance use overload resolution tricks and redirections.
For example, Eiffel covariance most likely only works in Eiffel, I doubt a
C# class calling it is going to be terribly pleased(infact it may not be
able to deal with the class at all, I dunno).

There is discussion of it, but I'm pretty sure the 2.0 framework won't
support it directly.
[quoted text, click to view]

Mickey Williams [C# MVP]
7/20/2004 5:50:02 PM
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:Oru9JcqbEHA.3524@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

That's true - if you look at the IL, the object returned is an instance of
the anchor type. It's strictly an Eiffel language thing - not too suprising,
since so few languages support covariance for fields, parameters, and
results. That's why I wrote these lines in:
message news:OujQh8nbEHA.1644@tk2msftngp13.phx.gbl...

[quoted text, click to view]

Strictly an Eiffel language feature...

--
Mickey Williams
Author, "Visual C# .NET Core Ref", MS Press
www.neudesic.com
www.servergeek.com

Daniel O'Connell [C# MVP]
7/20/2004 9:26:04 PM

"Mickey Williams [C# MVP]" <my first name at servergeek dot com> wrote in
message news:%23nDjNwrbEHA.1048@tk2msftngp13.phx.gbl...
[quoted text, click to view]

Ya, I missed the "strictly" in that. Sorry, ;). I am curious if methods with
covariant return types work in other languages or if they cause the
compilers to balk. To lazy to find and try eiffel though.
[quoted text, click to view]

Hasani (remove nospam from address)
7/21/2004 9:32:03 AM
Well, created my post with c++.net and c# in mind.
What is the definition of a method/function signature, I thought it a
function's name, and the parameters/arguments. The return type can be
different
so
int Foo()
void Foo()
const char* Foo()

all have the same method/function signature.

"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:eKD0TosbEHA.3944@tk2msftngp13.phx.gbl...
[quoted text, click to view]

Mickey Williams [C# MVP]
7/21/2004 10:59:06 AM
[quoted text, click to view]

The signature does include the return type, but in C#, you can't overload
based only on the return type. You can change the return type in an overload
only if you also change the signature of the parameter list in some way.

--
Mickey Williams
Author, "Visual C# .NET Core Ref", MS Press
www.neudesic.com
www.servergeek.com

AddThis Social Bookmark Button