D vs C++ classes?

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Tue Jun 29 06:52:03 UTC 2021


On Monday, 28 June 2021 at 23:17:36 UTC, Bruce Carneal wrote:
> Making a new feature optional does not, of course, actually 
> make it free.  The cost includes, minimally, the cost of 
> implementation and maintenance over the life of the compiler(s) 
> and the debugging costs incurred by programmers encountering 
> bugs in the, potentially complex, new compiler code.

The complexity that comes with multiple inheritance is the offset 
to the ancestor class, but that is already solved by the C++ ABI 
one chooses to conform to.

The diamond problem isn't about what to do when merging members, 
which seem to have been what people have focused on in this 
thread, but whether you want the common ancestor A to have two 
instances or one instance. So in C++ you solve this by making the 
shared ancestor `virtual` if you want to have one ancestor 
instance. Which is a bit clumsy, but I guess this comes down to 
requirements inherited from C-style separate compilation.

Still, C++ is what it is, so compilers have to deal with it 
regardless. Unifying C++ and D classes gets rid of one language 
construct (The D class). So it does make the language simpler for 
the user in my view.



More information about the Digitalmars-d mailing list