Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ucla-cs.ARPA Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!zehntel!hplabs!sdcrdcf!trwrba!cepu!ucla-cs!matt From: matt@ucla-cs.UUCP Newsgroups: net.lang.c Subject: Re: Using &LABEL Message-ID: <1327@ucla-cs.ARPA> Date: Mon, 24-Sep-84 04:35:42 EDT Article-I.D.: ucla-cs.1327 Posted: Mon Sep 24 04:35:42 1984 Date-Received: Wed, 26-Sep-84 19:15:14 EDT References: rabbit.3115, <3185@ecsvax.UUCP> <9406@brunix.UUCP> Organization: UCLA CS Dept. Lines: 31 #endif BUG >>Bennet Todd suggests that arrays of labels might be useful >>for jump tables. That's exactly the purpose of the >>switch statement. >true, but what if you want to update the jump table on the fly? >(not that I would personally want to-- it does seem a bit hacky-- but > this is, after all, a discussion of what "might be useful") How about using an extra level of indirection in the switch statement? Instead of: switch(i) { ... } use: switch (jump[i]) { ... } The `jump' array can be updated on the fly, of course. The possible values of `i' should be packed as tightly as possible for effective memory utilization in the `jump' array. The extra execution cost for this method is likely to be neglible in all but the most demanding applications. Now can we get rid of &LABEL? - Matt ------- UUCP: {ucbvax,ihnp4}!ucla-cs!locus.matt ARPA: matt@ucla-locus