Re: why no struct inheritance?



Paul Werkowitz <newsgroups@xxxxxxxxxxxxxxxx> wrote:
Am Wed, 16 May 2007 18:32:04 +0100 schrieb Jon Skeet [C# MVP]:

[snipped]
Its a matter of opinion, ok.

But to your last statement I have a question:
There is complexity in adding the feature of deriving from structs.
There is also a benefit to it. The question is whether the benefit
outweighs the cost in complexity or not. I don't believe it does, you
presumably do. That's a perfectly reasonable matter of opinion.

What complexity do you see in the feature of deriving from a struct? We
have no polymorphism here, only the possibility to override functions and
add new ones.

And add new fields, presumably. However, you *do* still need to learn
what is and isn't now allowed, and what should happen in various cases.
There's more to learn, and for little benefit IMO. (I very rarely write
my own value types to start with, and can't remember ever wanting to
derive one value type from another.)

To write non-trivial programs in C#, you need reference
types, derivation, polymorphism, ..... the whole enchilada. Such a person
should be able to grasp the concept of derivation of value types, too,
IMHO.

Yes, but in the same way that someone who has learned a difficult
language (e.g. Welsh) should be able to learn a relatively simple
language (e.g. French). That doesn't mean they would instantly *know*
French having learned Welsh. They'd have more to learn. I'm all for
keeping the language as simple as possible unless there's a really good
benefit to be gained from adding complexity (e.g. the addition of
generics and nullable types). Just MHO though.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: ``Ken and I being on the radio together
    ... "grammar" at all in school (personally, I express no opinion on the ... matter), then it makes sense to point out this particular idiosyncracy, ... especially if his other language had no ... it's useful (for writing better essays, papers, job applications, ...
    (sci.lang)
  • Re: why no struct inheritance?
    ... That's a perfectly reasonable matter of opinion. ... What complexity do you see in the feature of deriving from a struct? ... To write non-trivial programs in C#, you need reference ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: "Dangerous Roads"
    ... >>> language to express it is immaterial. ... opinon doen't enter into the discussion. ... You object to his opinion and seem to think that this makes ... The cause of a collision is not a matter for opinion, ...
    (uk.rec.driving)
  • Re: with statement
    ... gain isn't a great idea in my opinion. ... Yes, introducing a "with" statement increases complexity, but that's true of anything you include in a language. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Array of buttons... identify button on click
    ... But our company has over a million lines of code written using hungarian in ... language you don't speak. ... Anyway this is off topic and I guess it boils down to a matter of opinion ...
    (microsoft.public.dotnet.framework.compactframework)