Feedback on Átila's Vision for D

IGotD- nise at
Tue Oct 22 14:37:25 UTC 2019

On Monday, 21 October 2019 at 10:46:40 UTC, Alex wrote:
> This is interesting. Can you provide a source of why the 
> nominal type system is a contradiction to the current approach?
> I mean, currently I can follow Meta more:
> If you have an object implementing both, Debug and Display, 
> then the class has to implement foo. And if it does, it can be 
> handled by functions both handling Debug and Display. The 
> ambiguity is solved at this level:
> ´´´
> interface De{ void foo(); }
> interface Di { void foo(); }
> class C : De, Di{ override void foo(){} }
> void main()
> {
>     auto c = new C();
>     //c.fun1; //fails to compile, as you would expect
>     De de = c;
>     Di di = c;
>     de.fun1;
>     di.fun1;
> }
> auto fun1(De de){; }
> auto fun1(Di di){; }
> ´´´
> So, for sure, if you want to have different overloads for 
> different interfaces, then, they can't go into the class of C. 
> But there is no need to do so.

I don't understand why multiple inheritance is allowed except 
this lethal "diamond problem" has been implemented in a language 
which would seem to be a fair limitation. I have programmed C++ 
for decades and I have never used virtual inheritance when 
diamond like inheritance has happened, zero times. Also I have 
never encountered I had to rearrange the inheritance in order to 
avoid the diamond problem. However, I use multiple inheritance 
often in terms of that one class inherits from several other 
classes but the inheritance is fairly flat and the inherited 
classes never have any common parent class.

More information about the Digitalmars-d mailing list