Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!lll-crg!lll-lcc!dual!proper!hoptoad!gnu From: gnu@hoptoad.uucp (John Gilmore) Newsgroups: net.lang.c Subject: Re: case stmt != jumptable of goto labels !!!!!!!!! Message-ID: <553@hoptoad.uucp> Date: Mon, 24-Feb-86 22:37:44 EST Article-I.D.: hoptoad.553 Posted: Mon Feb 24 22:37:44 1986 Date-Received: Fri, 28-Feb-86 06:53:10 EST References: <324@yetti.UUCP> Organization: Nebula Consultants in San Francisco Lines: 23 Keywords: case, jumptable It is true that a case (in C, "switch") statement is not the same as a jump vector, because the vector cannot be modified. However, a trivial hack gives the behaviour you want: int vector[MAX_JUMPS]; switch (vector[i]) { This costs one subscripting operation per jump -- a price, but a small price. Not nearly the overhead of a function call, for example. I've seen exactly this kind of contruct used for the inner loop of an interpreter. It probably works OK for a regular expression scanner, or lexer, too. You can even do it one better by declaring int *vector; and pointing it at whatever jump table you are currently interested in, out of a set of precompiled or dynamically built jump tables. Are we having done yet? -- John Gilmore {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu jgilmore@lll-crg.arpa