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,99222a5bd46ef3c9 X-Google-Attributes: gid103376,public From: Karel Th�nissen Subject: Re: GOTO considered necessary (reworked) Date: 1997/06/25 Message-ID: <33B06738.311C@hello.nl>#1/1 X-Deja-AN: 252347544 References: <5nn2fm$11dk$1@prime.imagin.net> <199706121410.QAA05823@basement.replay.com> <33A0840B.1B41@sprintmail.com> <33A58C79.1C7A@sprintmail.com> <33A8DB59.776F@hello.nl> <33AE29D6.7258@sprintmail.com> Organization: Hello Technologies, Netherlands Newsgroups: comp.lang.ada Date: 1997-06-25T00:00:00+00:00 List-Id: John G. Volan wrote: > > I would not suggest inventing an entirely distinct syntactic gizmo for > Ada (or any similar language), simply because there would not be a > sufficient number of applications to warrant the added complexity in the > language. I am not able to judge the frequence in sufficiently large sample of code. > How about this instead: [snipped: standard loop+case implementation of FSM] > pragma Finite_State_Automaton (FSA_Name, State); > This pragma would enforce the following criteria: [snip on list of semantic constraints for the pragma] These are the semantics I had in mind too. > The advantage of using a pragma for this rather than a new syntax is > that it doesn't require any actual change in the language definition. > Instead, it just layers some special-case semantics on the existing > syntax of the language, which seems quite appropriate for this special > case situation. The nice thing is that the code will work even if your compiler does not understand the particular pragma. At the expense of missing the additional security of course. However, we should be careful (in general) not to extend this kind of reasoning to far, because then we end up with a language design in which everything is handled by the simplest of all control structures (the infamous goto) that does all the dirty work, monitored by a couple of pragmas that check semantic constraints for particular patterns (loops, selections, etc.). If they are supported, that is. > I suppose a similar sort of pragma might be devised for the code+goto > style, requiring that every conditional branch within a given code-block > end with an explicit goto. Guess so. > But again, it's hardly worth the effort to design and implement such a > pragma, given the low demand for FSAs in most software. Or is that because FSM's are avoided because people do not recognize them or fear the goto-based programming that is implied? FSM's have more applications than lexical analysis alone: communication protocols, process description in discrete simulation, user interface interaction at various levels, games, control tasks in operating systems, ... Groeten, Karel