home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!iphasew!igor!thor!rmartin
- From: rmartin@thor.Rational.COM (Bob Martin)
- Newsgroups: comp.lang.c++
- Subject: Re: GOTO, was: Tiny proposal for na
- Message-ID: <rmartin.714929724@thor>
- Date: 27 Aug 92 15:35:24 GMT
- References: <714668024@thor> <6800007@tisdec.tis.tandy.com> <1992Aug26.130335.26725@hemlock.cray.com> <MATT.92Aug26122422@physics16.berkeley.edu>
- Sender: news@Rational.COM
- Lines: 31
-
- matt@physics16.berkeley.edu (Matt Austern) writes:
-
- >The classic situation where gotos are generally believed to be useful
- >is writing a finite-state machine.
-
- >It seems to me that you could probably do better, though, by defining
- >some abstract class State, and then deriving the actual states of the
- >finite-state machine from it; this seems like it might be a more
- >elegant technique. (I haven't tried this, though; I'm just
- >speculating.)
-
- Get the C++ report, Vol 3, Number 1, January 1991. The banner article
- provides a detailed description of your speculation.
-
- I have since used that techinque in dozens of applications, and have
- even written a yacc/lex parser which takes a traditional State
- transition table and converts it into the necessary C++ code. (I'll
- send it to you if you like).
-
- ------
-
- Goto has never been a "good" way to implement FSMs. Nested
- switch/case statements which use a State variable and transition codes
- are more traditional, easier to maintain, and do not use goto.
-
-
- --
- Robert Martin Training courses offered in:
- R. C. M. Consulting Object Oriented Analysis
- 2080 Cranbrook Rd. Object Oriented Design
- Green Oaks, Il 60048 (708) 918-1004 C++
-