6 ms·
Unironically this. Having "interfaces" and "abstract classes" is just a kludge, multiple inheritance covers all of this with one language construct. The "diam
by LAC-Tech 2y ago
Unironically this.
Having "interfaces" and "abstract classes" is just a kludge, multiple inheritance covers all of this with one language construct.
The "diamond problem" is a C++ issue, every other language solved it.
- lyu07282 2y agoI think they solved the problem by not supporting multiple inheritance, instead supporting interfaces and/or traits. But also "composition over inheritance" pretty much won, thankfully imho.
- hakanderyal 2y agoMixins via inheritance is a sweet pattern that I miss in C# sometimes.
- mastry 2y agoC# has default interface implementations now, that can be used to create mixins... https://learn.microsoft.com/en-us/dotnet/csharp/advanced-topics/interface-implementation/mixins-with-default-interface-methods https://learn.microsoft.com/en-us/dotnet/csharp/advanced-top...
- hakanderyal 2y agoYeah I sometimes use them but they don’t cover all the cases. I’m waiting for roles/extensions to see if I can achieve a similar result. https://github.com/dotnet/csharplang/discussions/5496 https://github.com/dotnet/csharplang/discussions/5496
- LAC-Tech 2y agohttps://en.wikipedia.org/wiki/Multiple_inheritance#Mitigation https://en.wikipedia.org/wiki/Multiple_inheritance#Mitigatio... CLOS and Ocaml figured it out
- freilanzer 2y agoWhen in doubt look to CLOS.
- consteval 2y agoThe "diamond problem" isn't a C++ problem. C++ solved it with virtual inheritance. Also C++ has exactly what you want. No interfaces, multiple inheritance. People don't utilize it unless it's a GUI lib.