switch break

Roy M. Silvernail roy%cybrspc at cs.umn.edu
Sun Oct 7 13:39:22 AEST 1990


dkeisen at Gang-of-Four.Stanford.EDU (Dave Eisen) writes:

> In article <RVJJq3w163w at cybrspc> roy%cybrspc at cs.umn.edu (Roy M. Silvernail)
> writes:
> >Continue, though, is already a keyword for loop control. Giving it two
> >seperate and context-dependant tasks would, IMHO, _really_ screw people
> >up. 
> 
> Break, though, is already a keyword for loop control. Giving it two
> separate and context-dependent tasks would, IMHO, _really_ screw people
> up.
> 
> Oh hell, I guess they'll muddle through somehow.

Actually, Dave, I didn't really present my point clearly. I should have
said "seperate, context-dependant and _differing_ tasks".

The break keyword, of course, is used now to:

1) terminate a case in the switch statement.

2) force immediate termination of a for, while or do loop.

Thinking about this, I find both uses consistant with each other, as
they both stop the current iteration of a control structure.

The suggested addition to continue, though, isn't consistant. Currently,
continue causes the current control structure to reiterate. The
suggested use within a switch would do exactly the opposite, and cause
the control structure to progress. A switch can be viewed as a loop that
only executes once. Redefining continue within a switch? Just a disaster
waiting to compile. (ask the nameless AT&T programmer about break vs.
if...)

But you're right... we'll all muddle through. ;-)
--
Roy M. Silvernail |+|  roy%cybrspc at cs.umn.edu  |+| #define opinions ALL_MINE;
main(){float x=1;x=x/50;printf("It's only $%.2f, but it's my $%.2f!\n",x,x);}
"This is cyberspace." -- Peter da Silva  :--:  "...and I like it here!" -- me



More information about the Comp.lang.c mailing list