From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,deeb88b0e7eede4f X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Help with Exceptions! Date: 1996/05/14 Message-ID: #1/1 X-Deja-AN: 154767820 references: <4n9uas$pq0@newsbf02.news.aol.com> organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1996-05-14T00:00:00+00:00 List-Id: In article <4n9uas$pq0@newsbf02.news.aol.com> johnherro@aol.com (John Herro) writes: > I'm not saying that the following is any "better" than the above, but > here's how I would do it, without recursion. > Retry : Boolean := True; > I : ... := ...; > ... > while Retry loop > Retry := False; > while I < ... and not Retry loop > ... > if entry_type = continue then > ... > Retry := True; > end if; > I := ...; -- e.g., I + 1 or ...'Succ(I) > end loop; > end loop; > Again, I'm not saying this is better, but my point is that you could > "fix" the goto without recursion. Your implication is correct, this is a lot worse. ;-) "Fixing" the flow with state variables either requires at least second loop, two state variables, multiple settings of the state variable or duplication of the code for reading the table header. (In this two loop variation, you can go back to a for loop for the inner loop since the continue entry occurs last--if you use are willing to use a loop exit or return statement to get out in the "normal" case. Otherwise you need a second state variable.) All of these are abortions that I wouldn't put in any code I wrote in preference to a single goto and label. Not only do the alternatives obfuscate the actual logic, but some create unexecutable paths through the code that require a lot of reasoning to verify. The recursive solution is slightly messy because you often need four or five parameters in a real parser, but at least the logic is clean. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...