Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't think braces solve that particular problem:

    if (null != foo);
    {
      bar();
    }


It does if you use the One True Brace Style:

http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS

since your eyes would flag:

    if (null != foo); {
       bar();
    }
as badness.

[edit: correct } to {, ta]


As someone who programs in Go a lot these days, that line (I assume you meant the first curly to be { and not }) looks less obviously wrong than it would have in the past when I did more C/C++ programming.

Because I've gotten used to Go's support for short assignment in an if, the semi doesn't look completely out of place there (though the construction here is not valid Go either).


I agree. This is we do

   if (null != foo) bar();
or

   if (null != foo) {
       bar();
   }




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: