[net.lang.c] I break for

cottrell@nbs-vms.ARPA (COTTRELL, JAMES) (10/01/85)

/* Terry Poot writes:
> >	for (;;) {
> >		ch=getch();
> >		if ((ch>='1'&&ch<='5')||ch=='E') break;
> >		putchar(BELL);
> >	}
> Some of us feel the same about breaks as we do about gotos. I won't use
> it, or continue either, and I won't let anyone in my shop use it. It is
> just a goto with an implicit label, and destroys the ability to
> determine program flow from the FORM of the source even more
> drastically, as there is no label to catch your eye and alert you to the
> presence of the d*mned thing. The only way I will use a break is in a
> set of macros implementing a middle exit loop construct. We use
> LOOP...LOOPUNTIL...ENDLOOP. I know, adding features to a language with
> #define has problems, but at least that code is readable once you know
> what the constructs do, which is quite apparent. C should have that
> structure built in. Since it doesn't, we add it. The keywords are at the
> same indentation level, of course. 

Chicken! There is nothing wrong with a break statement. Most *real*
programmers don't have any difficulty with it, so why do you?
The fact that there is no label is a blessing, as then you can
jump there from *anywhere*, so you have to look for it. I suppose you
don't like `return's in the middle of a funxion either! Most of us
would rather see a well used break than an extra `if' statement
surrounding the `broken :-)' code and and extra boolean flag.

On the other hand, maybe C should have two kinds of breaks, one
for loops, one for switches. Multiple breaks have been discussed
before (please not again) & the general consensus seems to be
1) these aren't used too often & therefore there is no *pressing* need
2) you can easily miscount levels so just use a goto.

You will not receive my resume in the mail. Or many others.
 
> (-: Someone challenged me to produce flames. This should do it :-)

Yer durn tootin!


	jim		cottrell@nbs
*/

------

mzal@pegasus.UUCP (Mike Zaleski) (10/03/85)

> Some of us feel the same about breaks as we do about gotos. I won't use
> it, or continue either, and I won't let anyone in my shop use it. It is
> just a goto with an implicit label, and destroys the ability to
> determine program flow from the FORM of the source...

I guess this means you don't use the switch statement either.
Not that you can't live without it, but it can be useful at times.
Without a break, a switch statement is kind of unwieldly.

-- Mike^Z   Zaleski@Rutgers   [ allegra!, ihnp4! ] pegasus!mzal

preece@ccvaxa.UUCP (10/03/85)

/* Terry Poot writes:
> Some of us feel the same about breaks as we do about gotos. I won't use
> it, or continue either, and I won't let anyone in my shop use it. It is
> just a goto with an implicit label, and destroys the ability to
> determine program flow from the FORM of the source even more
> drastically,...
----------
Well, it's nice to be able to infer meaning from form (we love you,
Mies), but break and continue are much clearer than the alternative
of bracketing off the remaining code within the loop.  If there's more
than one break in a loop any other method leads to horrible
structures that may explicitly expose the flow of the program but
are guaranteed to give the reader instant migraine.  I think you
should lay out your code so that the break is very obvious (separate
line, with comment), but you shouldn't avoid using them.

It is unfortunate that they used the same word for breaking from a
loop and terminating a case clause in a switch statement.

-- 
scott preece
gould/csd - urbana
ihnp4!uiucdcs!ccvaxa!preece