3 ms·
> The overuse of newlines in coding standards is... a useless exercise. My clojure code is more vertically compact (despite sticking to 80-column lines and avo
by dkersten 8y ago
> The overuse of newlines in coding standards is... a useless exercise.
My clojure code is more vertically compact (despite sticking to 80-column lines and avoiding deep nesting) than a lot of C++ code I see out there:
if (condition)
{ // wasted line
some = code(here);
} // another wasted line?
// sometimes a blank line here too
if (another condition)
{
...
The Java convention at least wastes a tiny bit less vertical space:
if (condition) {
some = code(here);
}
if (another condition) {
...
In Clojure I have the same, but without the trailing closing brace. I insert blank lines if I need to visually break the code up or if its really unrelated from the previous line, but its up to me when to apply it based on when it makes sense to do so, not just because the naming standard says so.
(if condition
(some code here))
(if another-condition
...)
In reality, I'd of course use when and if the body is trivial then I may even simply write (when condition trivial-body) as one line. As long as it won't go over 80 characters.