Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!sri-spam!mordor!lll-tis!ptsfa!ihnp4!inuxc!iuvax!pur-ee!j.cc.purdue.edu!k.cc.purdue.edu!l.cc.purdue.edu!cik From: cik@l.cc.purdue.edu (Herman Rubin) Newsgroups: comp.lang.c Subject: Re: goto's in C: an opinion... Message-ID: <559@l.cc.purdue.edu> Date: Sun, 26-Jul-87 08:26:53 EDT Article-I.D.: l.559 Posted: Sun Jul 26 08:26:53 1987 Date-Received: Sun, 26-Jul-87 21:41:11 EDT References: <3289@bigburd.PRC.Unisys.COM> <7571@beta.UUCP> <6172@brl-smoke.ARPA> Organization: Purdue University Statistics Department Lines: 34 Summary: But I have a spaghetti algorithm In article <6172@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: > In article <556@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: [details omitted] > That's an example of the sort of thing that gave GOTO a bad name. > If you draw connecting paths between the gotos and their targets, > you get the infamous "spaghetti". It is always POSSIBLE that such > code is correct, but it is not patent from its structure. Indeed, > it's not even clear that the branching necessarily terminates, and > the termination condition if written out would be exceedingly > complex. By the way, how is label "termd" reached? Are you sure > this code is correct? Would you be comfortable making serious > revisions to it a few years from now? I really can't recommend > this style of coding. First, I gave only a disjointed fragment of the code, not enough to produce the flow. Second, there is random input at all stages of the code before reaching a terminating condition, and I can only state that the code terminates with probability one, but the expected termination time is short. Third, I doubt that I would be able to prove the correctness of the algorithm without knowing what the purpose of each section is; however, knowing this, it is not difficult. The procedure is a modification of a more easily described algorithm, but using the minimum amount of random information to carry out each stage--only isolated random bits are used. Fourth, it would be folly to attempt to revise this code without that description. If you think you can produce better code with or without the use of goto's, please let me know and I will give you the opportunity, but note that by better I mean faster. -- Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907 Phone: (317)494-6054 hrubin@l.cc.purdue.edu or pur-ee!stat-l!cik or hrubin@purccvm.bitnet