Re: Compiler error found... I was wrong, This is a logic error by design
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 03/06/05
- Next message: Morten Wennevik: "Re: How to handle Ctrl+Enter"
- Previous message: Joshua Flanagan: "Re: How to handle Ctrl+Enter"
- In reply to: -: "Re: Compiler error found... I was wrong, This is a logic error by design"
- Next in thread: Larry Brasfield: "Re: Compiler error found... I was wrong, This is a logic error by design"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 6 Mar 2005 15:30:17 -0000
- <-@hotmail.com> wrote:
> Hi Jon and Larry (I reply here once for both of yours)
>
> First of all, thx for your feedback, and I have to say you are completly
> rigth, I was wrong.
> The compiler behaves as expected by lang. spec..
>
> Conclusion:
>
> The ? : operator can not be used in polimorphic way. For example we can not
> write:
>
> Fruit myFruit = flag ? new Lime() : new Orange();
>
> The question is: What was the Architect reason to disable this?
>
> Lang spec expects Orange to be type compatible (can implicitly cast) to
> Lime. This is a logic mistake, and very poor interpetation of
> polimorhism. Both Lime and Orange must be compatible with left side, but not
> with each other, because programmer never wanted to convert them to each
> other, Then why the language spec want to do?
I believe it's so that each expression has a type associated with it
which is independent of the use of the expression.
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: Morten Wennevik: "Re: How to handle Ctrl+Enter"
- Previous message: Joshua Flanagan: "Re: How to handle Ctrl+Enter"
- In reply to: -: "Re: Compiler error found... I was wrong, This is a logic error by design"
- Next in thread: Larry Brasfield: "Re: Compiler error found... I was wrong, This is a logic error by design"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|