Re: Compiler error found... I was wrong, This is a logic error by design

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 03/06/05


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


Relevant Pages

  • Re: Panasonic VS6?
    ... any feedback from owners? ... TIA:) ...
    (uk.telecom.mobile)
  • Re: Dimension 8300: Can it support "high density" memory?
    ... the spec calls for "128Meg x 64" in the 1gb config ... Check out the HUNDREDS of mutual feedback ... I guess from my past experiences, ... are known (which they've appeared in this thread eleventy billion times.) ...
    (alt.sys.pc-clone.dell)
  • Panasonic VS6?
    ... I am looking to get my wife a new phone for birthday, looks a good spec, any ... feedback from owners? ... TIA:) ...
    (uk.telecom.mobile)
  • RE: Adding File to Import File Spec
    ... >Jackie, thanks for the feedback. ... I had to create a new import spec with the new ... >> In Access 97 I can edit an existing file import ...
    (microsoft.public.access.tablesdbdesign)