What happened to label variables?

Paul Dietz dietz%slb-doll.csnet at CSNET-RELAY.ARPA
Sun Mar 2 13:45:45 AEST 1986


>> [the lack of label varibles in C] is unfortunate...

>I don't think you will get much sympathy on this point.

I certainly wasn't suggesting the use of label variables by human
programmers.  However, like gotos, they make writing
source-to-source translators easier in some cases (such as
mine).

You suggested:

> 	switch(labelindex) {
> 		case 1: label1: <code> break;
> 		case 2: label2: <code> break;
> 		...
> 		case n: labeln:	<code> break;
> 		default: fprintf(stderr,"unknown label index: %d\n",
> 					labelindex);
> 			 abort();
> 	}

Unfortunately, this doesn't always work.  Some of the label1 ... labeln may be
inside additional switch statements.  In any case, using a switch statement is
still slower than a jump to a label variable, since the object code must
check if the index is out of range (the VAX does this in microcode but
it's still slower than a jump).

>> [Do any current compilers have indirect jumps...?]
> Probably not. I think they all wised up. Why don't you?

Because I want to generate C, and I want efficient code.  The switch
hack is contorted and inefficient.



More information about the Comp.lang.c mailing list