Can we just have struct inheritence already?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Jun 10 14:42:41 UTC 2019


On 6/10/19 4:03 AM, Manu wrote:
> On Mon, Jun 10, 2019 at 12:30 AM Andrei Alexandrescu via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>>
>> On 6/9/19 5:13 PM, Manu wrote:
>>> This is NOT polymorphism, we're not talking about polymorphism, I wish
>>> people would not change the topic.
>>
>> The problem here is that it's difficult to define subtyping without
>> polymorphism. C++ does technically allow it, but code such as:
>>
>> struct my_vector : public std::vector<int> { ... }
>>
>> is universally reviled. I really think it wouldn't help D much to add
>> struct inheritance.
> 
> We do it anyway though, it's just terrible.
> How will it cause any harm to anybody?

The same way it causes in C++. Crack open literally any C++ introductory 
book to find the explanation.

> I hate this idea that something
> has shown to be sorely missed for so long, and we still can't
> reconsider it because some moron out there might write bad code?
> D almost exclusively attracts power-users, who have unbelievably
> complex software to get on with. Tools are good, especially tools like
> this which only make a shitty piece of existing language much cleaner
> and simpler to reason about.

Nonsense. Again: the feature exists in C++ and is explicitly forbidden 
by all coding standards. If they could turn the time back they wouldn't 
have it. So... why would we now imitate it alongside with its mistakes? 
If you have a great idea on how to improve on it, sure. Otherwise, just 
don't.


More information about the Digitalmars-d mailing list