Breaking out of labeled statements - (nf)

alan at allegra.UUCP alan at allegra.UUCP
Thu Sep 1 00:13:24 AEST 1983


	Another thing that would be very useful in case statements
	would be a 'recase'  verb, which would restart the enclosing
	switch (i guess in C it would be 'reswitch'). It is often useful
	to be able to recognize some cases as only minor variants of
	others, and process them by using a prologue for one variant
	followed by the existing case treatment shared between them.
	A reswitch verb would make this trivial.


In certain cases, C allows you to do exactly what you're asking for.

	switch (a) {

	  case ONE_THING:
		/* code for ONE_THING */
		break;

	  case A_VARIATION_ON_A_SECOND_THING:
		/* prologue, then fall through... */

	  case A_SECOND_THING:
		/* common code for A_SECOND_THING and variation */
		break;

	}

Of course, there can't be two variations, each with its own prologue,
of one case, so this is of limited use.


	Alan Driscoll
	Bell Labs, Murray Hill



More information about the Comp.lang.c mailing list