http://qs321.pair.com?node_id=11146111


in reply to Re^4: How has your coding style changed over the years?
in thread How has your coding style changed over the years?

I'm curious to know why the opening brace goes on the conditional line.

It is reassuring that someone else uses the same argument for indented braces that I do. It seems to be a highly unusual thing!

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
  • Comment on Re^5: How has your coding style changed over the years?

Replies are listed 'Best First'.
Re^6: How has your coding style changed over the years?
by Tux (Canon) on Aug 12, 2022 at 06:12 UTC

    The opening brace goes on the line of the statement because

    • It saves vertical space: now I can see more code on my screen/window and have a bigger (over)view on the context
    • As the closing vrace, it is just syntax and by that reason does not deserve a line of its own
    • The closing brace has a line of its own, because the last line in the block is likely to change or new lines to be inserted before the brace.

    (In an ideal world, my editor should optionally replace the line with the closing brace with a (coloured) hairline starting at the left indent of the block till the right edge of the windown.)

    Maybe obvious from above: I am not a big fan of too much vertical whitespace. I'd forbid more than one blank line between logical blocks.


    Enjoy, Have FUN! H.Merijn