D vs C++ classes?

mw mingwu at gmail.com
Tue Jun 22 13:48:36 UTC 2021


On Tuesday, 22 June 2021 at 09:04:05 UTC, IGotD- wrote:
> On Tuesday, 22 June 2021 at 02:13:33 UTC, zjh wrote:
>>
>> multiple inheritance is very good.I dont know why they are 
>> objective.
>> 10+ years ago,they refuse to listen others' suggestion.
>> I dont know if they still refuse now.
>
> It's because the diamond problem. The diamond problem is purely 
> an academic problem and it very seldom happens in the real 
> world and if it does you probably did something wrong in your 
> design. Happen to me once in 30 years because I messed up.


Forgive me to repeat: diamond problem is a solved problem, 
elegantly by Eiffel, see my previous post, and example on github:

https://forum.dlang.org/post/deeuyrcwxjkjerpgqdjj@forum.dlang.org

> Multiple inheritance is often flat, which means that one class 
> inherits from several others at the same level. Instead of 
> disallow multiple inheritance you can disallow the diamond 
> pattern.
>
> D went another way with composition with template mixins. 
> Nothing particular wrong with this model but I think the D 
> documentation isn't clear about its intended use. Also the 
> overlap with alias this makes it more confusing.




More information about the Digitalmars-d mailing list