5 ms·
Read David Tribble's "Go To Statement Considered Harmful: A Retrospective" instead: http://david.tribble.com/text/goto.html http://david.tribble.com/text/goto.
by GrumpyYoungMan 7y ago
Read David Tribble's "Go To Statement Considered Harmful:
A Retrospective" instead: http://david.tribble.com/text/goto.html http://david.tribble.com/text/goto.html . It contains the entire text of Dijkstra's paper and goes over its meaning in a modern context on a paragraph-by-paragraph basis. It's very well written and makes clear the "encourages spaghetti code" argument, while true at the time, applied in a era where basic control flow constructs that we now take for granted did not exist in commonly used languages.
- nybble41 7y agoThank you for the recommendation; that was a very interesting read. I find that I can't quite agree with the last "nontrivial goto" example, though. This version without explicit gotos is actually shorter, and IMHO not really any more difficult to follow: int parse(void) { Token tok; while ((tok = gettoken()) != END) { while (!shift(tok)) if (!reduce(tok)) return ERROR; } return ACCEPT; } I will say that any language without goto, or where the use of goto is discouraged, should at least provide guaranteed tail-call elimination as an alternative. In this case the gotos could easily be converted into loops, but not every algorithm is so accommodating.