Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ncoast.UUCP Path: utzoo!watmath!clyde!burl!hou3c!hocda!houxm!ihnp4!zehntel!dual!amd!decwrl!decvax!cwruecmp!atvax!ncoast!bsa From: bsa@ncoast.UUCP (The WITNESS) Newsgroups: net.lang.c Subject: Re: Using &LABEL Message-ID: <331@ncoast.UUCP> Date: Sun, 16-Sep-84 21:18:17 EDT Article-I.D.: ncoast.331 Posted: Sun Sep 16 21:18:17 1984 Date-Received: Tue, 25-Sep-84 06:12:17 EDT References: rabbit.3115, <3185@ecsvax.UUCP> <9406@brunix.UUCP> Organization: North Coast XENIX, Cleveland Lines: 32 [gollum :-)] > From: rch@brunix.UUCP (Rich Yampell) > >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") Might be, or perhaps "is". I have already made use of, on my own, a "call table" using the following struct: struct cmdtab { char *c_name[10]; int (*c_fn)(); }; This is used in a program where a number of options exist, depending on the first character of the command string: '!' shells it, '#' execs it, and '*' does a lookup in the cmdtab list. I could see uses for a "label table" in this, for special-purpose operations (such as an exit statement; currently, you have to prefefine an exit character, making it difficult to build tables on the fly, but a label option would fix this while providing for other contingencies as well). I haven't tried it, though; it probably won't work on someone's machine, and I am trying to be halfway portable. (And failed already; the tables built on the fly are directory menus, and won't work under 4.2. :-) (I LOVE compatibility :-) --bsa