Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rochester!pt!ius1.cs.cmu.edu!edw From: edw@ius1.cs.cmu.edu (Eddie Wyatt) Newsgroups: comp.lang.c Subject: Re: goto's in C: an opinion... Message-ID: <1022@ius1.cs.cmu.edu> Date: Sun, 26-Jul-87 22:00:13 EDT Article-I.D.: ius1.1022 Posted: Sun Jul 26 22:00:13 1987 Date-Received: Mon, 27-Jul-87 03:44:31 EDT References: <3289@bigburd.PRC.Unisys.COM> <7571@beta.UUCP> <765@haddock.ISC.COM> <960@fmsrl7.UUCP> Organization: Carnegie-Mellon University, CS/RI Lines: 42 Keywords: C, goto, style In article <960@fmsrl7.UUCP>, grazier@fmsrl7.UUCP (Kevin Grazier) writes: > sequence. When you're running real-time code which is running something like > an engine, you look for speed ANYWHERE. This is another case in which > practicality diverges slightly from the theoretical. Buy yourself one hell of an optimizing compiler or write it in assembly if your code is that time critial. > > On a more intangible level, I seem to remember being taught as an undergrad > that there are still a COUPLE (and I mean just that) algorithms that > can't be done without a goto. Unfortunately, I can't remember what they > did, though. If this receives too many flames, maybe I'll have to look > it up. What the instructor was trying to show by this example, though, was > that there are, indeed, only a COUPLE algorithms which cannot be done > without gotos and that since we weren't doing anything near as complex, > we shouldn't use them (actually couldn't use would be more proper because > if you used one, you flunked the assignment). > Sorry, but ALL computable problems can be coded with ONLY while statements and if-then-elses for flow of control. In fact I'll go one step farther, ALL computable problems can be coded with only ONE while statement and if-then-elses. Every Von Newman machine is an example of this. while (1) fetch instructure /* can be viewed as an array index */ decode instructure /* can be decoded with only if-then-else think about */ execute instruction /* goto statements are actually just set PC = label */ inc PC I sugguest you pick up a book on Automata Theory and formal languages. The actually theorem that states if gotos are over kill was derived in the 30's by Kleene. I also sugguest you look up Church-Turning Thesis. -- Eddie Wyatt e-mail: edw@ius1.cs.cmu.edu