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 autolearn=ham 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 06:03:50 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uwm.edu!newsfeed.cs.wisc.edu!nnxp1.twtelecom.net!news-east.rr.com!news-west.rr.com!news.airnews.net!cabal10.airnews.net!cabal1.airnews.net!news-f.iadfw.net!usenet From: "John R. Strohm" Newsgroups: comp.lang.ada Subject: Re: Future with Ada Date: Thu, 14 Mar 2002 07:36:59 -0800 Organization: Airnews.net! at Internet America Message-ID: <3110CD47C49024FD.F939AB71201FA5BA.C9BEAE8D87E18DEA@lp.airnews.net> X-Orig-Message-ID: References: <3C901A57.FC90C430@despammed.com> X-A-Notice: References line has been trimmed due to 512 byte limitation Abuse-Reports-To: abuse at airmail.net to report improper postings NNTP-Proxy-Relay: library1-aux.airnews.net NNTP-Posting-Time: Thu Mar 14 08:02:33 2002 NNTP-Posting-Host: !e%C#1k-W4^")oK (Encoded at Airnews!) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:21227 Date: 2002-03-14T07:36:59-08: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. 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. "Wes Groleau" wrote in message news:3C901A57.FC90C430@despammed.com... > > > > I think I'd be tempted to use an array of access-to-procedures here. > > > > > That would certainly be an interesting approach .... > > The technique you suggest hadn't occurred to me & I could see it as useful > > and probably a good idea for a lot of cases. I just wouldn't imagine it > > It's a super way to make a state machine. If the inputs > can be enumerated, and the states can be enumerated, then > you have a two-dimensional array, indexed by current state > and input. Each element is a record containing next state > and transition action procedure pointer. > > Logic is just a tight loop looking up what to do and > next state. > > Aggregate to initialize the array can be laid out > easily in a tabular format suitable for documentation-- > or copied _from_ the requirements. > > -- > Wes Groleau > http://freepages.rootsweb.com/~wgroleau