Using &LABEL

The WITNESS bsa at ncoast.UUCP
Mon Sep 17 11:18:17 AEST 1984

[gollum :-)]

> From: rch at 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 :-)


More information about the Comp.lang.c mailing list