{"id":1551,"date":"2011-09-26T16:00:50","date_gmt":"2011-09-26T23:00:50","guid":{"rendered":"https:\/\/www.reenigne.org\/blog\/?p=1551"},"modified":"2011-09-08T14:22:03","modified_gmt":"2011-09-08T21:22:03","slug":"getting-rid-of-gotos","status":"publish","type":"post","link":"https:\/\/www.reenigne.org\/blog\/getting-rid-of-gotos\/","title":{"rendered":"Getting rid of GOTOs"},"content":{"rendered":"<p>It&#8217;s well known that it&#8217;s possible to change a program that uses GOTOs into one that uses loops and conditionals if you&#8217;re allowed to duplicate code or add more variables. One very easy way is just to change the program into a state machine, with one state for each label and a big loop around the whole thing. But under what conditions can you eliminate GOTOs if you can&#8217;t do either?<\/p>\n<p>The &#8220;Multiple break&#8221; example in <a href=\"https:\/\/www.reenigne.org\/blog\/more-keywords\">the &#8220;More keywords&#8221; blog post<\/a> is a piece of code that can&#8217;t be de-GOTOized in C. I&#8217;m wondering if there are any examples of pieces of code that can&#8217;t be de-GOTOized without multiple break, extra variables or code duplication. If I understand the abstract of <a href=\"http:\/\/dl.acm.org\/citation.cfm?id=362337&#038;dl=ACM&#038;coll=DL&#038;CFID=38916776&#038;CFTOKEN=92062495\">Peterson 1973<\/a> correctly I think there aren&#8217;t &#8211; that multiple break is enough to make GOTO redundant (but I can&#8217;t find a non-paywalled copy of that article to check, and I don&#8217;t care enough to spend $15 to find out).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s well known that it&#8217;s possible to change a program that uses GOTOs into one that uses loops and conditionals if you&#8217;re allowed to duplicate code or add more variables. One very easy way is just to change the program into a state machine, with one state for each label and a big loop around [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-1551","post","type-post","status-publish","format-standard","hentry","category-language"],"_links":{"self":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/comments?post=1551"}],"version-history":[{"count":1,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1551\/revisions"}],"predecessor-version":[{"id":1552,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1551\/revisions\/1552"}],"wp:attachment":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/media?parent=1551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/categories?post=1551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/tags?post=1551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}