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=0.2 required=5.0 tests=BAYES_00,FROM_ADDR_WS, INVALID_MSGID,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,86fd56abf3579c34 X-Google-Attributes: gid103376,public From: Dan Kurfis Subject: Re: State machines and Goto's (was Re: Should internet support software be written in Ada?) Date: 1995/03/29 Message-ID: <3ldnmh$hi5@maple.enet.net>#1/1 X-Deja-AN: 100540650 distribution: world references: <3kaksj$iur@isnews.calpoly.edu> <3ki9t8$c8l@Starbase.NeoSoft.COM> organization: Self mime-version: 1.0 reply-to: dkurfis@enet.net newsgroups: comp.lang.ada Date: 1995-03-29T00:00:00+00:00 List-Id: In article , eachus@spectre.mitre.org says... > > The only goto's I have ever used in Ada, PL/I, Algol, etc. have >been either in compiler testing or in state machines. (The former is, >of course, no reason to include them in a language.) So AFAIK, the >only legitimate use of gotos are in state machines. > > Of course, compiler builders are among the most prolific users and >builders of state machines, so compiler builders want to retain gotos. >The question is does that justify their inclusion in modern >programming languages? My guess is that the answer is no, but that it >is a close call. However, the cost to implement gotos is small, and >compiler writers will always voluteer to pay it. > > Although I can appreciate the "goto" argument for conversion tools and (maybe) compilers, most of my embedded applications include at least one state machine, and I've never had to use the goto construct. Perhaps my state machines aren't terribly complex...the toughest one I've done involves two separate state machines to implement X.25 layer 2 (HDLC) and a modified version of X.25 layer 3. I've never built a compiler, so I really can't compare the levels of complexity. Each of the X.25 state machines are (basically) simple tasks containing one main loop enveloping a (huge) case construct. I've always believed this to be the best mechanism to implement these particular state machines, but I'm always open to new ideas. Finally, although the cost to implement gotos may be small (to a compiler manufacturer), the cost to MAINTAIN code with gotos (to a software maintainer) can be enormous. I've done my time in maintenance and development of large FORTRAN (IV and 77) systems, and languages like Ada are a Godsend to me... Dan Kurfis