Hacker News new | ask | show | jobs
by dblohm7 1592 days ago
One of the first codebases I ever worked on professionally allowed gotos as part of its style guide, but only under two conditions:

1. You're using the goto for error handling and cleanup in a function; and

2. You only jump in a forward direction.

2 comments

The C `switch` statement and `goto` were made for each other, too.
Used like this, it is not much different than a try-catch block
Yeah and it's make sense to use it this way since there is no try-catch in C.
Reminds me of BASIC best practices:

    ON ERROR GOTO handler
    [try code here] 
    GOTO finally

    handler:
    [catch code here]

    finally:
    [finally code here]