Several ongoing PRs address different aspects of encapsulation:
Looking at the earlier attempts referenced by #35511 (#4067 and #5430 from 2014), what strikes me is that the same fundamental design questions have been debated for more than twelve years, with essentially the same arguments repeated over and over.
The fundamental engineering question is not particularly exotic. Encapsulation has been an established principle of software engineering for decades: a type should expose its semantics, not its representation.
Yet we continue to debate individual applications of this principle as though each were a new architectural question. The cost and risk of changing existing code repeatedly become arguments for retaining the coupling that makes those changes costly and risky in the first place.
I propose that we adopt encapsulation and regular value semantics as general design guidelines for vocabulary types:
- Data members should be
private. Public member functions and free functions should express meaningful operations rather than merely reproduce access to the underlying representation through getters and setters. No inheritance or abstract base classes are implied. - Vocabulary types should have regular value semantics, including copyability and assignability. This rules out
constand reference data members, which prevent ordinary assignment.
This issue proposes a design guideline, not a rewrite or refactoring initiative. Identifying existing violations, planning migrations, and evaluating the costs and risks of individual changes are outside its scope. Those questions belong in the respective implementation PRs.
The purpose of this issue is to establish a shared engineering direction, so that future reviews can focus on how to apply these principles rather than repeatedly debating whether they should apply at all.