{"id":12278,"date":"2024-07-01T11:13:35","date_gmt":"2024-07-01T15:13:35","guid":{"rendered":"https:\/\/irreal.org\/blog\/?p=12278"},"modified":"2024-07-01T11:13:35","modified_gmt":"2024-07-01T15:13:35","slug":"gotos-considered-maybe-not-harmful","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=12278","title":{"rendered":"Gotos Considered Maybe Not Harmful"},"content":{"rendered":"<p>\nWay back in 1968, Edgar Dijkstra published a <a href=\"https:\/\/homepages.cwi.nl\/~storm\/teaching\/reader\/Dijkstra68.pdf\">famous letter<\/a> to the Communications of the ACM that explained why he felt the go to statement was being abused. Ever since then, lots of uninformed folks who haven&rsquo;t bothered reading it and have missed the nuances in Dijkstara&rsquo;s argument have been invoking it in what amounts to a jihad against using gotos in any circumstance. The letter almost wasn&rsquo;t published because the editors felt it wasn&rsquo;t that interesting and the famous title, &ldquo;Go To Statement Considered Harmful&rdquo; was actually written by one of the editors not Dijkstra.\n<\/p>\n<p>\nThe truth is, there are lots of circumstances in which gotos make perfect sense. I&rsquo;ve used them myself but I always felt the need to document why my use didn&rsquo;t violate some sacred dictum by referring to <a href=\"https:\/\/pic.plover.com\/knuth-GOTO.pdf\">this paper<\/a> by Knuth in the source code. It saved me a lot of pushback and I could tell those who persisted in arguing the point to direct their comments to Knuth.\n<\/p>\n<p>\nNow Joe Marshall offers another <a href=\"http:\/\/funcall.blogspot.com\/2024\/06\/goto-not-that-harmful.html\">example of acceptable goto use<\/a>. It&rsquo;s not clear from his post whether he&rsquo;s using an explicit goto or merely pointing out that gotos occur implicitly in <i>all<\/i> programming languages. Certainly, the example of tail recursion is like that. His point is that tail recursion is simply a goto even if there&rsquo;s no explicit goto involved.\n<\/p>\n<p>\nThe use of gotos that Dijkstra was arguing against is clearly a bad thing but that doesn&rsquo;t mean that their use in specialized situations is a sign of sin.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Way back in 1968, Edgar Dijkstra published a famous letter to the Communications of the ACM that explained why he felt the go to statement was being abused. Ever since then, lots of uninformed folks who haven&rsquo;t bothered reading it &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=12278\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,9],"tags":[],"class_list":["post-12278","post","type-post","status-publish","format-standard","hentry","category-general","category-programming"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/12278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12278"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/12278\/revisions"}],"predecessor-version":[{"id":12279,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/12278\/revisions\/12279"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}