On Thu, 14 Apr 2011 14:05:54 +0300, Shlomi Fish wrote: > Hi Uri and Peter, >> > Regarding the "Goto statement considered harmful" myth, see what I wrote > about it here:
"Myth" is generally used to descibe something widely thought to be true that is in fact false. The assertion that goto is harmful has hardly been proven false. > The entire "GOTO statement considered harmful" is quite a myth. Granted, > Dijkstra wrote an article with this title, and many people agreed with > him. But, on the other hand, some people have demonstrated that it is > possible to do structured programming with goto statements, and > sometimes even better with them than without them. Of course you *can* replace control structures with GOTOs, they all compile to machine code that uses either GOTO or program counter stacks anyway. The reason we even have GOTO in languages is because the first ones were assembler code that reflected the machine code. Ancient history. > For example, Don Knuth wrote an article "Structured Programming Using > Goto Statements" (rumouredly sub-titled "'Goto Statement Considered > Harmful' Considered Harmful") in which he deomnstrated exactly that. And > I take this view as well. Knuth's article is at http://citeseerx.ist.psu.edu/viewdoc/download? doi=10.1.1.103.6084&rep=rep1&type=pdf . He doesn't call Dijkstra's statement harmful. He spends half the paper discussing how to remove GOTOs and then brings up some cases where using them would make certain code run faster, which in 1974 was often more important than programmer time but almost always isn't now. Knuth also had spent time developing languages like MIX that needed GOTO; MIX was a hypothetical machine code (sort of an early Parrot). It included card punch devices and drum units. So he was used to writing programs that had to use GOTO. Only assembly programmers these days still need it. Like I said: I've never seen code that was clearer with a GOTO than without it. Shorter, maybe; faster, maybe, but not clearer. Even if I ever did, it would be the exception that proved an unusually universal rule. Any possible justification for a GOTO would be so arcane that it is counterproductive to suggest it at all in a beginner's group. -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ http://www.informit.com/store/product.aspx?isbn=0137001274 http://www.oreillyschool.com/courses/perl3/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/