its something i've been doing lately. It feels pretty clean & it saves a lot of vertical space which is nice but is also feels a bit taboo.It becomes slighly niggerlicious when you have many statements in the body like if(x){++x; y = 3; if(x%2) coninue; break;} but i still think its elegant-ish and if it isn't then you can always break it up into multiple lines at that point.Also since im making a whole thread feel free to post other taboo coding styles that are actually nice.
if(x){++x; y = 3; if(x%2) coninue; break;}
>>107703965>pretty clean>that are actually nice.shit taste
>>107703965Single line conditionals is forgivable, no spaces after if and while isn't.
>>107703965yeah I do this. I always put braces though. helps when I occasionally end up having to add lines to the branch
as long as it compiles and has some comments i do not fucking care
>>107703965I use it sometimes, but I have a strict rule: only if the body is 1 (ONE) statement. Avoids wasting 2 or 3 lines (depending on brace style) for 1-statement functions.On anything longer, having a newline separating statements feels cleaner and also the overhead of a couple of lines allocated to braces is no longer significant
shit taste and shit code. if (foo) DoFoo();if (bar) DoBar();while (!elements.empty()) { sum += elements.front(); elements.pop();}while (sum) if (sum % 2) print(sum);if (baz) if (sum > 30) print(print);
if (foo) DoFoo();if (bar) DoBar();while (!elements.empty()) { sum += elements.front(); elements.pop();}while (sum) if (sum % 2) print(sum);if (baz) if (sum > 30) print(print);
I just let the autoformatter do whatever the heck it wants with my code and I enforce this habit with lints this way I can just write without thinking about formatting and when I'm done the computer fixes it.In general though I don't like long lines. I tend to arrange things side-by-side if I can, even putting consoles and test outputs as sidebars. So I like using a bunch of lines: ideally each line does one thing. The benefit of one line = one thing is it's more difficult to miss things. Lines are numbered, they're uniformly spaced, they're all aligned according to nesting level.