News for hackers. Stuff that matters.
Re:Clay: A new language for generic programming (based on LLVM) by planckscnst on Monday July 26, 2010 @07:36AM (#1547692)
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.
Re:Clay: A new language for generic programming (based on LLVM) by zitterbewegung on Monday July 26, 2010 @08:28AM (#1547801)
There 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://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pd...

Re:Clay: A new language for generic programming (based on LLVM) by kssreeram on Monday July 26, 2010 @07:59AM (#1547750)
I 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

Re:Clay: A new language for generic programming (based on LLVM) by wccrawford on Monday July 26, 2010 @07:47AM (#1547722)
Goto 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.

Re:Clay: A new language for generic programming (based on LLVM) by fhub on Monday July 26, 2010 @07:48AM (#1547726)
goto 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
Re:Clay: A new language for generic programming (based on LLVM) by adamc on Monday July 26, 2010 @07:52AM (#1547736)
Sure, but in the factorial example, Clay uses goto to express iteration: http://bitbucket.org/kssreeram/clay/src/b1df8340f2b4/test/fa...
Re:Clay: A new language for generic programming (based on LLVM) by alnayyir on Monday July 26, 2010 @11:13AM (#1548218)
Linux kernel uses goto all over the place, if you know what you're doing, it doesn't matter.