comp.lang.ada
 help / color / mirror / Atom feed
From: jm59@prism.gatech.edu (John M. Mills)
Subject: Re: State Machine Implementation
Date: 1998/08/06
Date: 1998-08-06T00:00:00+00:00	[thread overview]
Message-ID: <6qcr71$3hd@acmey.gatech.edu> (raw)
In-Reply-To: 6qcauo$ef4$1@nnrp1.dejanews.com


>In article <35C90369.CFE8ED98@inficad.com>,
>  "Ray A. Lopez" <rdsys@inficad.com> wrote:
>> Does anyone have any implementions of a state machine?  The states would
>> be just an enumerated type and I am guessing you would use a case
>> statement.  Just looking for more info on how to implement this using
>> Ada.

I would consider something like:

type Handlers is array(STATE) of access function(...) return STATE;

(give or take the grammar, sorry).  Each handler is associated with one
state.  Each handler performs what action it can, then determines if the
machine's state has changed, returning the appropriate new or old value 
of STATE, which is used as the call index on the next iteration.

Advantages: clean logic from outside the machine, and no massive case branch
or decision tree. State handlers are totally decoupled from one another.

Disadvantage: no externally obvious logic flow.

-- 
 John M. Mills, Senior Research Engineer   --   john.mills@gtri.gatech.edu
   Georgia Tech Research Institute, Georgia Tech, Atlanta, GA 30332-0834
        Phone contacts: 404.894.0151 (voice), 404.894.6258 (FAX)
           "Lies, Damned Lies, Statistics, and Simulations."




  reply	other threads:[~1998-08-06  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-05  0:00 State Machine Implementation Ray A. Lopez
1998-08-06  0:00 ` State Machine Implementation (long) dana
1998-08-06  0:00   ` Tarjei Tj�stheim Jensen
1998-08-06  0:00 ` State Machine Implementation dennison
1998-08-06  0:00   ` John M. Mills [this message]
1998-08-06  0:00 ` Matthew Heaney
1998-08-06  0:00 ` Robert Dewar
1998-08-11  0:00 ` Bill Meahan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox