4 ms·
You mean Dijkstra [1]? The guy who figured out shortest-path-first routing algorithm, semaphores, reverse polish notation? The reason GOTO considered harmful (
by pnathan 15y ago
You mean Dijkstra [1]? The guy who figured out shortest-path-first routing algorithm, semaphores, reverse polish notation?
The reason GOTO considered harmful (read the paper) was to assist in formally verifying the semantics of programs. Essentially, GOTO constructs fork environments in the formal analysis, and make things really difficult to work with.
They also make informal reasoning more difficult unless you apply restrictions on how you structure your program.
Know your history before you insult the people who came up with principles.
https://secure.wikimedia.org/wikipedia/en/wiki/Edsger_W._Dijkstra https://secure.wikimedia.org/wikipedia/en/wiki/Edsger_W._Dij...
- morganw 15y agoThe article suggests as a replacement for break "but generally extracting a loop to a separate method/function (or at least putting it at the end of existing method) and using return instead will do the trick" return (from anywhere but the end of a function) is just as damaging to formal verifiability as continue, break or goto.
- pnathan 15y agoEhhh. Continue, break, return at least are well-formed with respect to the local environment. GOTO has no such restrictions (well, in older languages allowing arbitrary GOTOs)... that's why its considered harmful. The single-return principle is used for flowcharts & formal analysis ease. It'd be mildly interesting to do a retrospective of compilation & static analysis algorithms to see what more current research turns up with respect to the single-return rule's use.
- Tichy 15y agoDidn't know it was Dijkstra and didn't actually mean to insult anybody. I thought the 'GOTO' thing was just a community opinion that emerged sometime in the last century. Anyway, I still think break and continue are OK. Maybe they are not as bad as GOTO, and also I never run into problems with verification of my code.