The little things #1: Access control

This post is part of a series looking at little details of programming language design, mostly in the context of Carbon. Check out the series intro post for context and other entries. Let’s talk about public vs. private! Folks who know C++ may be familiar with these concepts, but here is a quick example: class MyType { public: void MyPublicFunction(); private: void InternalDetail(); }; One of the things that has always been frustrating to me are exactly how public and private work here. They introduce regions of declarations, not a single declaration. And the default depends on how you declare the class? 😤 This is almost certainly just a personal thing, and I have no evidence this is a real source of confusion, but it grinds my gears. Anyways, the result is: ...

March 26, 2023 · 805 words