Hacker News new | past | comments | ask | show | jobs | submit login

Are you like talking about failing to put a semicolon after an empty loop in C? Do you have an example of some C code in which the code compiled but is semantically incorrect that doesn’t involve empty loops?



One can write macros which behave differently if a semicolon is added after, or not. One might (correctly) argue that such macros are poorly written, and are in fact the bug, not the missing/extra semicolon per se, but the end result would be the same.

https://gcc.gnu.org/onlinedocs/cpp/Swallowing-the-Semicolon....

There are places where , can be used instead of ; and that would change the meaning, which would be a similar kind of bug.

Then there's optional semicolons in javascript. Same thing. Sometimes adding/missing can change the expression depending on what follows.

Nobody but nobody is going to come into an interview talking about the semicolon that the compiler caught. They are going to talk about the one where it could be there or not (like a break statement being there or not), which either way is perfectly legal code.

This is a wonderful candidate to have (taking the cue from previous commenter) because you can then ask, how soon after finding that bug did you enforce static analysis or at least a linter that enforced style so as to eliminate this kind of error?

Finally, to directly answer your question, I always reject style guides that say an empty loop can go on one line. You always, always, need a second line with just ';' so that it's blindingly obvious even with 3AM tired eyes. And yes that is a valid error that's hard to find once code is committed that works at least at one point and only later breaks.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: