News for hackers. Stuff that matters.
Re:Ways to get screwed by C by pavel_lishin on Thursday December 09, 2010 @10:27PM (#1990461)
At every company I've ever worked, curly braces were mandatory after if/elif/else statements and loops specifically because of #8.
Re:Ways to get screwed by C by endgame on Thursday December 09, 2010 @10:45PM (#1990510)
My standard approach is to only ever omit the braces when the entire if statement fits on a single line. I also enforce a hard 80-char limit on my lines, which prevents a single enormous line.
Re:Ways to get screwed by C by __david__ on Thursday December 09, 2010 @10:59PM (#1990542)
I personally hate an 80 character limit. I do wrap comments at 80 or 100 chars but code isn't read like english prose--It's very easy to read a long line of code and it makes a lot of sense (sometimes) to keep everything on one line. Especially if there are multiple similar lines where you can make the columns line up nicely.
Re:Ways to get screwed by C by endgame on Friday December 10, 2010 @01:47AM (#1990906)
I personally find that the limit means that you're not occasionally reading far away from the main body of code, which makes it easier for my eyes to track. An added bonus is the ability to put multiple files side-by-side, something not easily possible when lines can be of arbitrary length.
Re:Ways to get screwed by C by unwind on Friday December 10, 2010 @03:12AM (#1991044)
I hope "elif" wasn't mandatory though, people using #define to modify C's syntax are weird. :)

Runs and ducks.