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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fx16.iad.POSTED!not-for-mail From: Shark8 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:36.0) Gecko/20100101 Thunderbird/36.0a1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Things that OO programming lacks References: <87389olqie.fsf@ixod.org> <10d9w.55626$8w1.22302@fx12.iad> <150er0b62wsh3$.1xabmp81w5kdw.dlg@40tude.net> <1azsoc77wjhmi$.1grmnnlq033tz.dlg@40tude.net> <5yzci4a8snfg.1dfsqjyvneeym$.dlg@40tude.net> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@teranews.com NNTP-Posting-Date: Mon, 17 Nov 2014 19:21:43 UTC Organization: TeraNews.com Date: Mon, 17 Nov 2014 12:21:42 -0700 X-Received-Bytes: 2786 X-Received-Body-CRC: 1731123726 X-Original-Bytes: 2803 Xref: number.nntp.giganews.com comp.lang.ada:190791 Date: 2014-11-17T12:21:42-07:00 List-Id: On 17-Nov-14 10:28, Dmitry A. Kazakov wrote: > FSM are proven to be extremely > complex to use, error-prone and unmaintainable. That is because states are > as uncomposable as events are. If you add new or remove old states you are > in deep trouble. Not really; in Ada we'd just say: Type Event is ( 'a', 'b', 'c', 'd' ); Type State is ( Start, middle_1, middle_2, Stop ); Type Transition_Table is array (Event, State) of State; Type FSM(<>) is private; Function Create( Transitions : Transition_Table ) return FSM; Procedure Do_Event( State_Machine : in out FSM; Action : Event ); private Type FSM(Transitions : not null access Transition_Table) is record Current : State:= Start; end record; -- in the Body ... Function Create( Transitions : Transition_Table ) return FSM is ( Transitions => New Transition_Table'(Transitions), others => <> ); Procedure Do_Event( State_Machine : in out FSM; Action : Event ) is begin case Action is when others => null; -- Attach particular/special actions here. -- Also allow Ada to do case-coverage where -- possible. end case; State_Machine.Current:= State_Machine.Transitions(Action, State_Machine.Current); end Do_Event;