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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,affd14e05b8fb09a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-28 12:57:32 PST Path: archiver1.google.com!news1.google.com!news.glorb.com!border1.nntp.ash.giganews.com!nntp.giganews.com!local1.nntp.ash.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 28 Apr 2004 14:57:32 -0500 Date: Wed, 28 Apr 2004 15:57:31 -0400 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Hierarchical States Machines References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.90.114 X-Trace: sv3-c2rztqyTERvb6P5GfPbnShEpNapmqXAyJDIMsuaOEr/2jIbB+QN3lw3Xu8Wset8mP4zl5W43/EZrJAw!584A0IxQBg36FXHhxFWPDY66hWvg2rtJA+9qCEZ5/+2C83cUzVG3gIAzIUA4ig== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:7546 Date: 2004-04-28T15:57:31-04:00 List-Id: Fabien wrote: > Pretty new to ADA dev., i am currently trying to implement a > hierarchical state machine for my application. So far, i must confess > that i do not really get on well with it. I am thus looking for some > people who might have tried to do it and who could give me some useful > tips . > > Fabien > > pS : I don't look for a ready-to-use solution, just some help !!!!! Unlike any other type of software, goto is your friend. The reason that goto is normally deprecated is that it results in spaghetti code. However, if you are implementing a state machine, you need to reflect the structure of the actual state diagram, which may look like spaghetti. Also if you are implementing a table driven state machine, the best way to do it is to build a driver that is its own state machine. (Sort of like using a universal Turing machine to read a description of a Turing machine and emulate it.) Again, the use of gotos will allow you to write a driver so that its structure corresponds to the algorithm you are implementing. Incidentally, as far as I know, or for that matter most Ada experts know, this is the only area in Ada where you should use gotos. But goto has been kept in the language primarily because it is _necessary_ to create maintainable finite state machines, push-down automata, and the like. -- Robert I. Eachus "The terrorist enemy holds no territory, defends no population, is unconstrained by rules of warfare, and respects no law of morality. Such an enemy cannot be deterred, contained, appeased or negotiated with. It can only be destroyed--and that, ladies and gentlemen, is the business at hand." -- Dick Cheney