comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: State Machine Implementation
Date: 1998/08/06
Date: 1998-08-06T00:00:00+00:00	[thread overview]
Message-ID: <dewar.902413526@merv> (raw)
In-Reply-To: 35C90369.CFE8ED98@inficad.com

<<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.
>>

A case statement is possible certainly, and it is hard to know exactly what
you mean by "an implementation", since this is the sort of thing that occurs
all the time in a programs, and the application dependent details are 95%
of the code anyway.

Note that an alternative, probably more efficient, and for many people more
readdable way of coding a finite state machine in languages like Ada is
to use a label on each state, and goto's to effect state transition, thus
efficiently encoding the state in the program counter.

Some people have this silly allergy to goto's (a case of understanding an
important principle without really understanding it), but in fact this is
for many programmers one of the very few legitimate uses of gotos.





  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 ` Robert Dewar [this message]
1998-08-06  0:00 ` dennison
1998-08-06  0:00   ` John M. Mills
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 Matthew Heaney
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