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/13 Message-ID: #1/1 X-Deja-AN: 154639348 references: <4mmimq$s4r@hatathli.csulb.edu> <318F94D9.35AB@io.com> organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1996-05-13T00:00:00+00:00 List-Id: In article <319764DA.3A8C@io.com> Dave Jones writes: > Most others seem to have an experience similar to mine: "goto" > means you need to change your approach. So I was wondering, has > anyone out there ever encountered a situation where "goto" was > actually necessary? The only two cases in which I have used gotos in are: 1) Testing the compiler's implementation of gotos for correctness. 2) Implementation of table driven finite-state machines. The latter requires a bit of explanation. Machine generated FSMs can use lots of gotos, but I have never seen an Ada FSM generator which does that. Implementing the entire FSM by hand with gotos is heap bad juju. But often you want a state table entry to have the form (in pseudo-code): table-identifier table-type number-of-entries = 3 when input = x goto state yyy " " = y goto state zzz when others => continue with state abc. This allows parse tables to be stored more compactly, and is best implemented by having a loop over the table entries that contains a goto back to the code for reading to table headers when the default case is encountered. The code structure is: <