Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 5/22/85; site cbosgd.UUCP Path: utzoo!watmath!clyde!cbosgd!bowles From: bowles@cbosgd.UUCP (Jeff Bowles) Newsgroups: net.lang.c Subject: Re: Arcane C hacks? Message-ID: <1836@cbosgd.UUCP> Date: Tue, 18-Feb-86 22:42:08 EST Article-I.D.: cbosgd.1836 Posted: Tue Feb 18 22:42:08 1986 Date-Received: Thu, 20-Feb-86 01:32:48 EST References: <1700003@umn-cs.UUCP> Reply-To: bowles@cbosgd.UUCP (Jeff Bowles) Organization: AT&T Bell Laboratories, Columbus Lines: 35 (Gee, wasn't the article I'm replying to supposed to be here, too?) Well, anyway, the article I'm following up is one where a programmer asks why: int i; ... goto labels[i]; /* "levels" contains pointers to, well, * you get it... */ went away from C. [I guess it used to be valid. Hmmmm.] If you feel the need to do something like this, you probably want to just use a structure: struct bletch { int l_token; /* If you see this, */ void (*l_whither)(); /* then call this routine */ }; Then you can just do a table lookup, calling the appropriate routines for each item. Or, :-), you can use the "computed goto" that C provides: switch (i) { case 0: ... break; case 1: ... } The "table lookup" that C provides will usually do what you need, with minimal effort. If you're translating an assembler program and need to "jump to the location specified by the N'th element of this array", I suggest finding a BCPL compiler. Jeff Bowles Lisle, IL