Using &LABEL

matt at ucla-cs.UUCP matt at ucla-cs.UUCP
Mon Sep 24 18:35:42 AEST 1984


#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 at ucla-locus



More information about the Comp.lang.c mailing list