Reply to post: Re: “Goto statement considred harmful”

Radio 4 and Dr K on programming languages: Full of Java Kool-Aid

Stuart Castle Silver badge

Re: “Goto statement considred harmful”

"It would be much better in this case to use a 'goto' to jump immediately to a critical error handler rather than having to propagate the error condition through a potentially complex control flow graph."

Indeed, if the software you wrote was controlling a nuclear power station and an error occurred, the extra time spent propagating the error through a potentially complex control flow graph would probably be better spend initiating and monitoring the shutdown of the reactor. The delay may only be a few milliseconds, but in that sort of situation, even milliseconds could mean the difference between a safe shutdown and a disaster.

My own opinion is that like (say) a knife, goto is not intrinsically good or bad. A knife can be used to kill someone (arguably bad). It can also be used to help feed someone (arguably good). The same with Goto. Used correctly, it can be good. Used badly, it can be very bad.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon