Reply to post: “Goto statement considred harmful”

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

Anonymous Coward
Anonymous Coward

“Goto statement considred harmful”

Strange how this often gets brought up but nobody mentions Frank Rubin's criticism 'GOTO Considered Harmful Considered Harmful'.

Goto is one of those "it depends" things:

Case 1 (in 'C'). Within a function you see:

do_stuff();

Ah, a simple function call you think. Wrong - do_stuff() is a function-like macro which included a condition goto to a label else where in the function. Unstructured code with hidden semantics.

Case 2. A block of code monitoring a safety critical system:

if ( isThereAProblem() )

something_bad_has_happened = true;

/* More code related to normal operation */

/* Handle any errors */

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.

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