News for hackers. Stuff that matters.
Re:Overview: What are Cpp2 and cppfront? How do I get and bu... by phkahler on Sunday March 31, 2024 @06:29PM (#39888677)
>>> 2. Poor encapsulation, adding private functions requires recompiling all dependents

>> under what circumstances does (2) hold?

To add a private member variable or function, you need to put it in the class definition in the header file. Then anything that includes the header needs to be recompiled.

Re:Overview: What are Cpp2 and cppfront? How do I get and bu... by hkwerf on Sunday March 31, 2024 @06:35PM (#39888737)
Admittedly, adding a private member variable changes the object size and thus the ABI and thus requires recompilation of dependencies.

Thinking about that, is there any case in which private functions can end up in a vtable? In that case, it'd break ABI too.

Re:Overview: What are Cpp2 and cppfront? How do I get and bu... by NekkoDroid on Sunday March 31, 2024 @06:58PM (#39888969)
> is there any case in which private functions can end up in a vtable?

Yes, but it generally isn't something that is done.

https://godbolt.org/z/5oPovKzoT

Re:Overview: What are Cpp2 and cppfront? How do I get and bu... by ThouYS on Sunday March 31, 2024 @06:31PM (#39888702)
they don't need to be. dependents will continue functioning, because ABI hasn't changed
Re:Overview: What are Cpp2 and cppfront? How do I get and bu... by jstimpfle on Sunday March 31, 2024 @06:35PM (#39888731)
Now explain that to my build system.

But even if you managed to do that, first compilation is still much slower than it should be, because anlot of headers have to be included (transitively) to allow even declaring these fields and methods.