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,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,92c39a3be0a7f17d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-14 09:43:47 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!cambridge1-snf1.gtei.net!news.gtei.net!bos-service1.ext.raytheon.com!bos-service2.ext.raytheon.com.POSTED!not-for-mail Message-ID: <3C90E13B.DA861A8C@despammed.com> From: Wes Groleau Reply-To: wesgroleau@despammed.com X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en,es-MX,es,pt,fr-CA,fr MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Future with Ada References: <3C901A57.FC90C430@despammed.com> <3110CD47C49024FD.F939AB71201FA5BA.C9BEAE8D87E18DEA@lp.airnews.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 14 Mar 2002 12:43:23 -0500 NNTP-Posting-Host: 151.168.144.162 X-Complaints-To: news@ext.ray.com X-Trace: bos-service2.ext.raytheon.com 1016127826 151.168.144.162 (Thu, 14 Mar 2002 12:43:46 EST) NNTP-Posting-Date: Thu, 14 Mar 2002 12:43:46 EST Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:21243 Date: 2002-03-14T12:43:23-05:00 List-Id: > The catch is that such matrices for real state machines tend to be VERY > sparse. Most of the entries will be "Can't Happen/Error", indicating that > this input can't happen in that state. Explicitly listing all the error > combinations obscures the non-error cases. Perhaps. But Impossible : constant Transition_Record := ( Handler => Report_Murphys_Law, Next_State => Error ); Fatal : constant Transition_Record := ( Handler => Report_Error_And_Exit, Next_State => Error ); Error : constant Transition_Record := ( Handler => Recover_From_Error, Next_State => Start ); So most of the entries are Impossible, Fatal, or Error. > The obvious fix for that is a vector of 4-tuples > > (state input handler next-state) > > and an initialization-time routine that starts by prefilling the matrix with > error_cant_happen and an appropriate state, and then walks the vector > filling the matrix. This is good, too. It's a matter of judgment. In some cases, the two-dimensional state/input lookup table in tabular aggregate form is more readable. In others it might be more readable to say: State_Transition_Table : constant ...... := ((state, input, handler, next-state), (state, input, handler, next-state), ...... (state, input, handler, next-state), (state, input, handler, next-state)); EITHER could be autogenerated from a diagrammatic version in a C.A.S.E. tool. EITHER expresses the requirements clearly in compilable form. EITHER is much better than the .... elsif Current_State = ..... and Input = ..... then Handler (Current_State, Input); elsif Current_State = ..... and .... that I've seen too often. -- Wes Groleau http://freepages.rootsweb.com/~wgroleau