Those who hang the opening brace at the end of the line are the ones that drive me nuts.
Those who hang the opening brace at the end of the line are the ones that drive me nuts.
You don't know when you see one line indented if it is a line continuation or conditional logic (or both) And god help you if you accidentally delete one of those opening braces -- it's impossible to spot sometimes unless you look closely.
http://java.sun.com/docs/codeconv/html/CodeConventions.doc5....
The PEAR PHP coding standards recommend this:
http://pear.php.net/manual/en/standards.php
And, as has been pointed out, if you don't do this in Javascript the JS interpreter will helpfully insert bugs for you (in the form of extra semicolons).
When Ruby uses braces at all, opening braces are placed at the ends of lines. (Usually the closing braces are on the same line, though... most multi-line Ruby blocks use the "do...end" keywords.)
The issue doesn't come up in Python at all, right? Likewise Lisp.
So it seems that only programmers who take up C as a first language will be exposed to the opening-brace-on-its-own-line style before they become used to the other style.
} Is an abomination!
I understand that it came from Java. But even when I code in Java I'm braces-stand-alone. And this bit about semicolon insertion? Lies. All lies I tell you.
http://framework.zend.com/manual/en/coding-standard.php-file...
function bob()
{
--------------
On the same line as the function, I get: function bob() {
----------------
Much cleaner. Plus, I don't worry about being able to match braces against each other, I have an IDE that does that for me. (When my cursor is against one brace, it's partner is highlighted.)And sometimes they get confused about where the folding points are, which means you have to reload the file.
I just wish there was a good GUI editor on Linux with good folding support :'(