comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: Hierarchical States Machines
Date: Wed, 28 Apr 2004 15:57:31 -0400
Date: 2004-04-28T15:57:31-04:00	[thread overview]
Message-ID: <jrOdnQYzWKMxkQ3dRVn-hQ@comcast.com> (raw)
In-Reply-To: <fed2d60.0404281048.41d6c549@posting.google.com>

Fabien wrote:

> Pretty new to ADA dev., i am currently trying to implement a
> hierarchical state machine for my application. So far, i must confess
> that i do not really get on well with it. I am thus looking for some
> people who might have tried to do it and who could give me some useful
> tips .
> 
> Fabien
> 
> pS : I don't look for a ready-to-use solution, just some help !!!!!

Unlike any other type of software, goto is your friend.

The reason that goto is normally deprecated is that it results in 
spaghetti code.  However, if you are implementing a state machine, you 
need to reflect the structure of the actual state diagram, which may 
look like spaghetti.

Also if you are implementing a table driven state machine, the best way 
to do it is to build a driver that is its own state machine.  (Sort of 
like using a universal Turing machine to read a description of a Turing 
machine and emulate it.)  Again, the use of gotos will allow you to 
write a driver so that its structure corresponds to the algorithm you 
are implementing.

Incidentally, as far as I know, or for that matter most Ada experts 
know, this is the only area in Ada where you should use gotos.  But goto 
has been kept in the language primarily because it is _necessary_ to 
create maintainable finite state machines, push-down automata, and the like.

-- 

                                           Robert I. Eachus

"The terrorist enemy holds no territory, defends no population, is 
unconstrained by rules of warfare, and respects no law of morality. Such 
an enemy cannot be deterred, contained, appeased or negotiated with. It 
can only be destroyed--and that, ladies and gentlemen, is the business 
at hand."  -- Dick Cheney




  parent reply	other threads:[~2004-04-28 19:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-28 18:48 Hierarchical States Machines Fabien
2004-04-28 19:39 ` Marius Amado Alves
2004-04-28 19:57 ` Robert I. Eachus [this message]
2004-04-29  3:00   ` Randy Brukardt
2004-04-29  7:25     ` Martin Krischik
2004-04-29 20:37       ` Randy Brukardt
2004-04-29 12:10   ` Wojtek Narczynski
2004-04-29  3:58 ` Steve
2004-04-29  5:14   ` Robert I. Eachus
2004-04-29  6:36     ` tmoran
2004-04-29 16:36       ` Robert I. Eachus
2004-04-29 15:41   ` Marius Amado Alves
replies disabled

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