Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-tgr!tgr!cottrell@nbs-vms.ARPA From: cottrell@nbs-vms.ARPA (COTTRELL, JAMES) Newsgroups: net.lang.c Subject: Break Continued Message-ID: <1843@brl-tgr.ARPA> Date: Tue, 1-Oct-85 21:09:19 EDT Article-I.D.: brl-tgr.1843 Posted: Tue Oct 1 21:09:19 1985 Date-Received: Thu, 3-Oct-85 06:32:31 EDT Sender: news@brl-tgr.ARPA Lines: 46 /* > > 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,... > > Well, now we know that this cat's either got some impressive coding > techniques or doesn't use switch statements. There are only two uses of > break, namely to exit the middle of a loop or to get out of (and usually > terminate) a branch of a switch. If switch is used without break, I'd like > to see how the coding works. Other than that, using break only to get out > of the middle of a loop is fairly unspectacular(!). Here's how he does his switches! It *really* works (under bsd 4.2 at least) main(argc) { int never = 0; switch (argc) { /* switch man sleepin' */ case 1: /* train a hundred & two */ printf("argc = 1\n"); /* is on the wrong track */ if (never) { /* & headin' for you! */ case 2: printf("argc = 2\n"); if (never) { case 3: printf("argc = 3\n"); if (never) { case 4: printf("argc = 4\n"); if (never) { default: printf("argc = ???\n"); } } } } } } Impressed? Well, you *did* ask! :-) > Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303)444-5710 x3086 > ...If you plant ice, you're gonna harvest wind. I'm not entirely sure I agree with you about adding construx to the language tho. I once saw this thruout a bunch of sources: #define repeat(x,n) for (x = 0; x < n; x++) On the other hand, if *that's* what it takes to scare off everyone from modifying my code, then macros away! :-) Whichever way your pleasure tends... jim cottrell@nbs */ ------