Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / July 2004

Tip: Looking for answers? Try searching our database.

Will 2.0 of the clr have support for covariant returns?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hasani \(remove nospam from address\) - 20 Jul 2004 02:38 GMT
Will 2.0 or some other future version of the clr have support for covariant
returns?
Mickey Williams [C# MVP] - 20 Jul 2004 18:33 GMT
"Hasani (remove nospam from address)" <hblackwell@n0sp4m.popstick.com> wrote
> Will 2.0 or some other future version of the clr have support for covariant
> returns?

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.

Signature

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

Daniel O'Connell [C# MVP] - 20 Jul 2004 23:15 GMT
> "Hasani (remove nospam from address)" <hblackwell@n0sp4m.popstick.com>
> wrote
[quoted text clipped - 8 lines]
> like their support for generics and MI. The generated IL is some complex
> kungfu.

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.
Mickey Williams [C# MVP] - 21 Jul 2004 01:50 GMT
> 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).

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...

> > 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.

Strictly an Eiffel language feature...

Signature

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

Daniel O'Connell [C# MVP] - 21 Jul 2004 03:26 GMT
>> For example, Eiffel covariance most likely only works in Eiffel, I doubt
>> a
[quoted text clipped - 18 lines]
>
> Strictly an Eiffel language feature...

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.
Hasani \(remove nospam from address\) - 21 Jul 2004 14:32 GMT
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.

> >> For example, Eiffel covariance most likely only works in Eiffel, I doubt
> >> a
[quoted text clipped - 22 lines]
> covariant return types work in other languages or if they cause the
> compilers to balk. To lazy to find and try eiffel though.
Mickey Williams [C# MVP] - 21 Jul 2004 18:59 GMT
"Hasani (remove nospam from address)" <hblackwell@n0sp4m.popstick.com> wrote
> Well, created my post with c++.net and c# in mind.
> What is the definition of a method/function signature, I thought it a
[quoted text clipped - 6 lines]
>
> all have the same method/function signature.

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.

Signature

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.