3 ms·
I find it interesting that goto is in the examples. I'm not deeply familiar with program theory and computability, but I thought goto made the program impossibl
by planckscnst 16y ago
I find it interesting that goto is in the examples. I'm not deeply familiar with program theory and computability, but I thought goto made the program impossible both to reason about and to verify its correctness. Why would one include it in a new programming language? Are there really valid uses of it? I don't think the factorial example here is a good use - he basically used it as a while(true) infinite loop. However, I also couldn't tell you with accuracy why it might be bad here other than the ingrained mentality of goto=evil.
- wccrawford 16y agoGoto isn't inherently evil. It allows bad (and newbie) programmers to make spaghetti code. It is taught as 'evil' to prevent them from using it when it would produce ugly code. Later, once you understand things, there are a few very rare times that it is legit to use it. Those few times can be handled without using it, though, and many programmers continue to avoid it out of habit or philosophy. As for including it in his new language, it looks like it's basically C with some syntactical sugar. He didn't so much 'include' it as fail to remove it. He got it for free from C.
- fhub 16y agogoto can be useful for "alarm exits". The linux kernel uses them a lot. See the bottom of this thread for some pseudo code http://kerneltrap.org/node/553/2131 http://kerneltrap.org/node/553/2131
- adamc 16y agoSure, but in the factorial example, Clay uses goto to express iteration: http://bitbucket.org/kssreeram/clay/src/b1df8340f2b4/test/factorial.clay http://bitbucket.org/kssreeram/clay/src/b1df8340f2b4/test/fa...
- kssreeram 16y agoI implemented goto because I've seen it being useful in other languages. That said, there's no other occurrence of goto in clay. http://stackoverflow.com/questions/24451/goto-usage http://stackoverflow.com/questions/24451/goto-usage
- zitterbewegung 16y agoThere are two trains of thought on goto. On one side Donald Knuth and Linus Torvalts consider goto useful in specialized operations. Knuth uses goto in certain operations where it would be optimal to have the construct. Linus allows them when it would be a good optimization strategy but you must use them sensibly On the other hand Edsger Dijkstra thought that having goto's in the language complicated the analysis of loops and also the analysis of the flow of the program. Dijstra did a great deal of research on structured programming which nearly all programming languages support (loop design, if then statements etc...) Citations: http://en.wikipedia.org/wiki/Goto#cite_note-4 http://en.wikipedia.org/wiki/Goto#cite_note-4 http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pd...
- alnayyir 16y agoLinux kernel uses goto all over the place, if you know what you're doing, it doesn't matter.