7 ms·
I never understand the desire to omit braces in single line blocks. sure for () foo saves you a line, but it's a bug waiting to happen.
by ja30278 12y ago
I never understand the desire to omit braces in single line blocks.
sure
for ()
foo
saves you a line, but it's a bug waiting to happen.
- oneeyedpigeon 12y agoAre there not examples where a statement is pretty much guaranteed to live on its own within a block? Having said that, my own style is to always include braces, for aesthetic reasons if nothing else.
- DrJokepu 12y agoPeople keep saying that, but do bugs like that really happen? In my entire career as a professional software developer I've never seen it happening. Not once.
- Arnt 12y agoApple's goto/fail bug could only exist because single-line then clauses work.
- hobo_mark 12y agoOh yes it does. https://www.imperialviolet.org/2014/02/22/applebug.html https://www.imperialviolet.org/2014/02/22/applebug.html
- DrJokepu 12y agoFair enough. That being said, -Wunreachable-code would have caught that.
- coolsunglasses 12y ago>Fair enough. That being said, -Wunreachable-code would have caught that. -Wunreachable-code was disabled in gcc years ago.
- DrJokepu 12y agoYes, but I would assume that Apple uses clang internally?
- lmm 12y agoA function or class that doesn't fit on a single screen is a bug waiting to happen.
- ams6110 12y agoWhen I omit braces I also omit the indented line. I would write: for () foo; Makes it clear it's ONE statement. At least for me...
- netheril96 12y agoThis makes debugging much harder.