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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.ada Subject: Re: Ada platforms and pricing, was: Re: a new language, designed for safety ! Date: Mon, 23 Jun 2014 20:18:00 -0500 Organization: Aioe.org NNTP Server Message-ID: References: <255b51cd-b23f-4413-805a-9fea3c70d8b2@googlegroups.com> <5ebe316d-cd84-40fb-a983-9f953f205fef@googlegroups.com> <2100734262424129975.133931laguest-archeia.com@nntp.aioe.org> <5156oy7vhg99.17wu6q2ef45ke.dlg@40tude.net> <18et97c0c22vc$.y98lxxfblijn.dlg@40tude.net> <08f83f70-ccb1-45ec-8a4c-46e3442745b8@googlegroups.com> Reply-To: nma@12000.org NNTP-Posting-Host: +bGw3iKtw0btMD059xlTWg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:20571 Date: 2014-06-23T20:18:00-05:00 List-Id: On 6/23/2014 4:48 PM, Simon Wright wrote: > "Dmitry A. Kazakov" writes: > >> The idiom is: unless at gunpoint, never ever use FSM. > > There are times when state machines aren't appropriate and there are > times when they are exactly the idiom you should be using. > I remember once struggling with so many IF/ELSEIF/ENDIF/WHILE, etc... trying to implement something, and then I learned about FSM programming. This was an application level, not low level system programming. Once I setup things as FSM, things went smooth sailing. Needed an initial state, final state, setup a diagram that tells me the event that causes which state to jump to which state. Once I drew this diagram, the coding part was easy. One can even setup a matrix that represent the algorithm. For example, writing TCP/IP algorithm and other network algorithms is nearly impossible without using the help of FSM. Here are diagrams: http://userpages.umbc.edu/~jeehye/cmsc491b/lectures/tcpstate/sld001.htm http://en.wikipedia.org/wiki/Border_Gateway_Protocol http://telescript.denayer.wenk.be/~hcr/cn/idoceo/tcp_linkstates.html I think also for parsing text, setting up a FSM makes parsing things much easier, and I used it for that also. FSM can be used for many other things if one can identify all the states and all the events that causes each state to switch to different state. http://en.wikipedia.org/wiki/Finite-state_machine --Nasser