What would break if class was merged with struct
Stanislav Blinov via Digitalmars-d
digitalmars-d at puremagic.com
Sat May 27 09:31:32 PDT 2017
On Saturday, 27 May 2017 at 16:23:33 UTC, Ola Fosheim Grøstad
wrote:
> On Saturday, 27 May 2017 at 16:04:42 UTC, Stanislav Blinov
> wrote:
>> It's not "a little bit", it's ABI down the drain, along with a
>> good part of runtime. And we'd lose interfaces and extern(C++).
>
> Why would you loose interfaces and extern(C++)?
>
> "struct" and "class" are interchangeable keywords in C++ (only
> affects encapsulation). So not a lot more difference than POD
> vs non-POD in C++?
There's a lot more difference in D. Classes in D are fat memory
chunks storing pointers to ClassInfo (inc. vtable), Monitor (i.e.
for "synchronized") and a list of all interfaces they implement,
that's before we get to data members. If we were to remove all
that, we'd lose the semi-natural way of interfacing to C++
classes, and some pretty horrendous code involving void* and
void** would have to be used.
More information about the Digitalmars-d
mailing list