To use goto or not?

后端 未结 9 1284
Happy的楠姐
Happy的楠姐 2020-12-14 17:34

This question may sound cliched, but I am in a situation here.

I am trying to implement a finite state automaton to parse a certain string in C. As I started writin

9条回答
  •  臣服心动
    2020-12-14 18:32

    Avoid goto unless the complexity added (to avoid) is more confusing.

    In practical engineering problems, there's room for goto used very sparingly. Academics and non-engineers wring their fingers needlessly over using goto. That said, if you paint yourself into an implementation corner where a lot of goto is the only way out, rethink the solution.

    A correctly working solution is usually the primary objective. Making it correct and maintainable (by minimizing complexity) has many life cycle benefits. Make it work first, and then clean it up gradually, preferably by simplifying and removing ugliness.

提交回复
热议问题