5 ms·
If you really cared about readability , you'd put your commas where normal human beings put them . Instead of in a silly place like that . Prefering structur
by agent327 5y ago
If you really cared about readability
, you'd put your commas where normal human beings put them
. Instead of in a silly place like that
. Prefering structure over normal communication is not
, typically
, seen as a good thing
.
- detaro 5y agoThat is the (or at the very least a) normal place to put them in C++. Human beings use things differently in different contexts.
- agent327 5y agoI've been a professional C++ programmer for 24 years now, and neither I, nor anyone I've worked with over this period, used this ridiculous style.
- fnord123 5y agoI've used it on larger teams where some enums for feature flags end up getting conflicts all the damn time when you add to the end because the last entry doesn't have a comma. This might be fixed in various languages/parsers by allowing a trailing comma (e.g. python). At the end of the day, clang-tidy, black, gofmt, rustfmt all the things and let's never talk about comma placement again.
- agent327 5y agoWhat if C++ actually allowed that comma? Because... it does.
- jcelerier 5y agonot everywhere, I often have a need for it in template arguments for instance for type lists: std::conditional< some_property< T, U, >, int, float, >; is a compile error, I really prefer std::conditional< some_property< T , U > , int , float >;
- fnord123 5y agoThat's only from C++11. The story I was telling you was from before then. $ cat test.cc enum Foo { FOO, BAR, }; int main(int argc, char** argv) { return 0; } $ g++ -std=c++98 -Wpedantic test.cc test.cc:3:5: warning: comma at end of enumerator list [-Wpedantic] 3 | BAR, | $ g++ -std=c++03 -Wpedantic test.cc test.cc:3:5: warning: comma at end of enumerator list [-Wpedantic] 3 | BAR, | ^ $ g++ -std=c++11 -Wpedantic test.cc
- isatty 5y agoIt’s a Haskell thing, and while I don’t use it in any other language, it does look very neat and readable in Haskell.
- Zagitta 5y agoHow many code bases have you actually worked on? I can tell you it's very common in constructor initializer-lists to the point that both the mozilla and webkit styles of clang-format does it.
- jcelerier 5y agohttps://stackoverflow.com/questions/10483635/why-do-lots-of-programmers-move-commas-to-the-next-line https://stackoverflow.com/questions/10483635/why-do-lots-of-... it just removes a lot of hassle when you are used to it, I'd never go back to trailing commas
- masklinn 5y agoPrefix separators are an excellent way to avoid diff noise in langages without terminators (/ trailing comma support).
- PennRobotics 5y agoThis is silly for several reasons that I will list: * Programming is not prose, so we can temper our expectations. * Even in prose, some symbols belong on the left, and some belong on the right. * The example given is no less readable than the alternative. * It's more important to be consistent in style than correct to one person's opinion e.g. some people still batch edit source via macros and appreciate when curly braces are not in unexpected places.
- tester34 5y agoHappen very often in SQL codes :(