Draft idea: constructor member designators
I’ve been experimenting with a small idea to make constructor initializer lists a bit clearer and less error‑prone. The idea actually came from a dilemma I had when trying to settle on naming conventions for member variables. Prefixes like m_ or _name help avoid shadowing, but they also feel like a workaround for something the language could express more directly.
I wrote a short draft exploring “constructor member designators” - a `.member` syntax for constructor initialization.
https://github.com/richardcervinka/cpp-constructor-member-designators
This is just an experiment, but maybe someone will find it interesting.
0
Upvotes
View all comments
Show parent comment
-9
u/aruisdante Mar 20 '26
It does not work if you have coding standards that explicitly forbid doing this, which is… a lot of them.
But this proposal wouldn’t solve that problem. The motivation is flawed: the reason these rules exist is not to avoid shadowing from a technological standpoint, but instead to avoid confusing if you’re writing to an argument or a member variable based on needing to know the shadowing rules.