[phobos] excessive vertical spacing?

Dmitry Olshansky dmitry.olsh at gmail.com
Mon Jan 28 12:51:18 PST 2013


29-Jan-2013 00:04, Jonathan M Davis пишет:
> On Monday, January 28, 2013 10:50:10 Andrei Alexandrescu wrote:
>> On 1/28/13 9:46 AM, Brad Roberts wrote:
>>> I actually prefer the blank line.
>> I'm surprised, but it's a good lesson to learn. I honestly believed
>> nobody would prefer that.
> I pretty much always put a blank line before return statements precisely so
> that they're visibly separate from the rest of the code. It's the same reason
> why I pretty much always have a blank line after vairable declarations or
> before or after if blocks or loops. It's less of a big deal in this
> particular case, because there's only one line of code above it, but I pretty
> much agree with Brad's reasoning on this. Blank lines are good for logically
> separating out sections of code, and I use them for that quite a bit.
And obligatory view from the other side of the fence.

I hate empty lines after "variable declarations or before or after if 
blocks".
D isn't Fortran and variables typically get defined right before being used
and go out of scope as soon as possible. Distinguishing if statements is
frankly strange in general, as fonts and editors provide enough of control
to make these stand out.

Same goes for putting a line before return statement - the return 
keyword is already
highlighted, and pretty much always expected. Most of the time (YMMV) 
it's either
an early return as (if+return) or the good old return at the end of 
function.

I'd say saved vertical space adds more clarity especially with modern 
wide-screen laptops ;)
And quite a lot of it is already wasted since we have "brace on its own 
line" as a style guideline.

I don't mind (and in fact like) empty lines that indicate semantic 
blocks or steps inside of a function.
I'd even put a comment in such a case. One of examples is the 
exception-safe code as there
is always a line between the stuff that may fail with exception (action)
and the stuff that shall never do (commit).

-- 
Dmitry Olshansky



More information about the phobos mailing list