Intelligibility of multibreak loops

ggs at ulysses.UUCP ggs at ulysses.UUCP
Fri Aug 26 00:44:02 AEST 1983


I think 'chongo's example of how one can survive without
the multi-level break is a demonstration of the need for
it.  Consider a slightly more complicated problem: you
want to get the next line if the line is bad, you want to
abandon the whole thing if the file is bad.  If you use
'break label' and 'continue label', you get the following:


	/* read lines of text ... */

readloop:
	for (; some-code; some-code) {
		...

		/* character in line processing */

		while (some-code) {
			...

			/* case in char in a line */

			switch (some-code) {
			...
			case BADLINE:
				...
				continue readloop;	/* get the next line */
				break;
			...
			case BADFILE:
				...
				break readloop;		/* stop reading */
			...
			}
		}
	}

I don't even want to think about how to write that using
convoluted flag testing, much less read it.
-- 

Griff Smith	Bell Labs, Murray Hill
Phone:		(201) 582-7736
Internet:	ggs at ulysses.uucp
UUCP:		ulysses!ggs



More information about the Comp.lang.c mailing list