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

> an unreachable code warning would have caught this particular defect, but it wouldn't have helped if the duplicated line were something other than a goto.

In that case always using curly braces or using a language that requires an "end" statement after the conditionally executed code may not have helped either. Imagine the incorrectly repeated statement was "a = a + 1" or "error_mask ^= error_x" etc. Putting the erroneous line inside the conditional doesn't erase the error, it just modifies the conditions under which it executes. That's about as likely to hang you as save you.



Is there any language rule that can save you from incorrectly repeating an operation that is not idempotent?




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

Search: