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=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cf677878aa77e0d8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-19 07:28:17 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: <3B4F2962.25BB60FF@boeing.com> <3B4F758B.197CA145@boeing.com> <9iv0ce$3d3$1@nh.pace.co.uk> <3B546F9D.4030809@gmx.net> <9j1u8a$863$1@nh.pace.co.uk> <3B56C6B2.559EE5F3@bsdger.org> Subject: Re: an infinate loop Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Thu, 19 Jul 2001 10:28:05 EDT Organization: http://www.newsranger.com Date: Thu, 19 Jul 2001 14:28:05 GMT Xref: archiver1.google.com comp.lang.ada:10249 Date: 2001-07-19T14:28:05+00:00 List-Id: In article <3B56C6B2.559EE5F3@bsdger.org>, Matthias Kretschmer says... >Another way of implementing a state machine would be to make an array of >subprogram access types to subprograms handling the different states. This >could be faster than using case with using the current state as an index to >the array. This should be nearly as fast as using goto, just it doesn't use >fixed jump-points. But if you just implement features because of speed >enhancements of special problems, than you should implement everything >including an assembler. Goto doesn't make it look worse, but make it may be >more complicated. Using for each state a seperate subprogram would be probably >make the whole stuff more appealing to the eyes of other people. To pull this off, you'd still need a loop around everything so you could iterate through the array. This is essentially the same as a case statement in a loop, except that you are replacing the "case" with an array. Another difference is that you now have subprogram call overhead for each state change. Often jump-table type code can be replaced with dynamic distpatch too, and that allows users to arbitrarily modify the routines in the jump-table without modifying the existing (debugged) sources. If this line of reasoning in lexical analysis interests you, you really ought to look into OpenToken, which implements it. See http://www.telepath.com/dennison/Ted/OpenToken/OpenToken.html