4 ms·
Thanks for bringing this up. There is no reason for modern languages that have proper constants (not preprocessor macros which happen to sometimes be used for t
by avgcorrection 3y ago
Thanks for bringing this up. There is no reason for modern languages that have proper constants (not preprocessor macros which happen to sometimes be used for them) to use this tedious style.
Constants are so innocent and useful. Why indirectly discourage their use by making their usage an eye-bleed?
- barbs 3y agoWhat alternative would you suggest?
- avgcorrection 3y agoWriting in a normal way in snake case or camel case or whatever the convention is.
- yakubin 3y agoIn C++ I do it Google style: static constexpr int kConstantName = 42;
- _moof 3y agoThis is the old Mac style too. Might just be my upbringing but I prefer it.
- avgcorrection 3y agoWhat's the point of the `k` prefix?
- smithza 3y agok for konstant
- avgcorrection 3y agoYes, that's what it stands for. What's the point of using any prefix at all?
- wrs 3y agoSo you don’t have to wonder if it’s a variable. Old Mac style uses prefixes: kConstant, gGlobalVar, TType, mMemberVar. Remember this was when all coding was done in black and white in a plain text editor.
- colejohnson66 3y agoHungarian notation
- Dylan16807 3y agoHungarian notation is for being more specific than the type system allows. When the type is already "constexpr int", that k isn't helping.
- dkersten 3y agoIMHO that’s much uglier than using caps. Sometimes when I use C++, I will namespace them however: namespace constants { static constexpr int name = 42; } … int x = constants::name; The exact name of the namespace would depend on the use and could be something more descriptive.
- deleted 3y ago[deleted]
- xigoi 3y agoJust use the same style as for variables. What's the point of the distinction? Maybe you'll want to change a constant into a variable later.