Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!harvard!bu-cs!bzs From: bzs@bu-cs.UUCP (Barry Shein) Newsgroups: net.lang.c Subject: Arcane C hacks? Message-ID: <184@bu-cs.UUCP> Date: Thu, 20-Feb-86 12:33:44 EST Article-I.D.: bu-cs.184 Posted: Thu Feb 20 12:33:44 1986 Date-Received: Sun, 23-Feb-86 06:13:09 EST Organization: Boston Univ Comp. Sci. Lines: 25 Re: what to do now that goto jumptab[x] is gone? Well, the obvious solution is a switch statement but that does not fulfill all your requirements and you probably rejected that. The way I do such things is to use an array of pointers to functions. In your example of jumping to on-the-fly generated code I suspect that is really what you are saying: On-the-fly generated functions, having an environment around the generated code is certainly not a bad thing and we assume you would like to come back sometime. Generating the prologue and epilogue to make the generated code a function should be more or less trivial as, besides stack offsets for autos, it's a cliche. So, the answer would be to declare a table something like: int (*funtable[MAXFNS])() ; /* did I get that right? array of pointers to functions returning int */ and just malloc the storage for the generated code. Obviously the return value needn't be int. I can't think of any reason off hand why this isn't powerful enough for what you propose. It should be quite portable (code generator aside) and is legal C. -Barry Shein, Boston University