4 ms·
You can understand what Dijkstra's comment was about, by reading both the original source (https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.pdf https
by svat 8y ago
You can understand what Dijkstra's comment was about, by reading both the original source (https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.pdf https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.p...) and the responses to it (the most comprehensive being Knuth's https://homepages.cwi.nl/~storm/teaching/reader/Knuth74.pdf https://homepages.cwi.nl/~storm/teaching/reader/Knuth74.pdf).
See for instance page 277 in Knuth's paper:
> Comparison of Features
> Of course, event indicators are not the only decent alternatives to go to statements that have been proposed. Many authors have suggested language features which provide roughly equivalent facilities, but which are expressed in terms of exit, jump-out, break or leave statements.
It goes on to discuss more alternatives (at least one of which I find in fact better than the "break" and "continue" we happen to have got with C). It also mentions:
> what I believe is really the most common situation in which go to statements are needed by an ALGOL or PL/I programmer, namely [a loop which is performed "n and a half times"]
This is also what the linked article discusses in section 4.1, the first one under "Common uses" (http://web.sonoma.edu/users/l/luvisi/goto/goto.pdf#page=5 http://web.sonoma.edu/users/l/luvisi/goto/goto.pdf#page=5).
If you restrict Dijkstra's comment to only apply to arbitrary jumps such as those into another function, then it does it a great disservice: there's no force in the argument anymore (it's a banal claim that nearly everyone always agreed with... in fact some of the languages in which goto was being debated at the time didn't even support such non-local gotos), and there would have been no controversy. It's worthwhile to consider thoughtfully the stronger claim that Dijkstra actually made (“the go to statement should be abolished from all 'higher level' programming languages (i.e., everything except, perhaps, plain machine code)”).
- SilasX 8y ago> It's worthwhile to consider thoughtfully the stronger claim that Dijkstra actually made (“the go to statement should be abolished from all 'higher level' programming languages (i.e., everything except, perhaps, plain machine code)”). But that claim sidesteps whether break, continue, early return, and try/except count as being the same, in spirit, as the literal 'go to'. "Don't literally use goto" is just as banal as you're claiming "don't goto the inside of another function" is. All the proffered examples of "good goto" are just explicit versions of break etc.
- svat 8y agoThe rest of my comment (everything except the last sentence you quoted) was precisely about showing that the debate was about, and did cover, break, continue, early return, etc. And yes, the examples given at the time of places were goto was useful are what would now be written with "break", "continue", etc., precisely because those were at risk of getting worse under a blanket "let's abolish goto" -- from which we can draw the conclusion that the debate at the time was indeed about them, and not merely about things like jumps into other functions. If we're debating what Dijkstra's comment was about at the time, and what the ensuing debate was about (a historical question), IMO we should do that by reading/quoting the primary sources, and not each other's comments. :-) I think we actually agree BTW. -------------------- Let me try rewording. At the time Dijkstra wrote his letter, "goto" was being used in many ways. The controversy ignited by Dijkstra's letter was whether all those uses of goto should be abolished. (That's why there was any debate at all; if Dijkstra had only said "let's remove jumps inside another function" there wouldn't be as much disagreement.) During this debate, people identified cases where "goto" was indeed necessary/useful, and those people were right, as we can see from the fact that some of those control flow mechanisms were introduced into languages under names like "break", to cover those examples. And yes, more recent languages like C have relatively tame gotos as well, as you said in the original comment. Both sides can be said to have won some points thoroughly: Dijkstra's (and others') warning against the "disastrous effects" of the goto statement led to languages locking down the kinds of "goto" they provide, and the other side's examples of useful "gotos" (in the languages of the time) led to languages almost universally incorporating "break", "continue", early returns, error-handling mechanisms, etc., to widen the scope of control flow that was possible without "goto". Try programming in some of the common languages circa 1968 (which didn't have these) without using "goto", and you'll see why there was a debate. :-) (Restricting Dijkstra's argument to only that part of it that eventually won thoroughly would make it appear that people were idiots for arguing against it, which is both historically inaccurate and ignores the influence from those arguments over current languages. And of course, restricting his argument to only the part that "lost" would make it seem like he was wrong and ignore his immense contribution, but I don't think I did that, did I? If I did, my apologies: my comment is relative to the present time, and what I think many people misunderstand about the debate historically.)