Article View: comp.lang.c
Article #187Re: Taming The Switch-Statement
From: Janis Papanagnou
Date: Sun, 11 Oct 2026 08:36
Date: Sun, 11 Oct 2026 08:36
30 lines
2978 bytes
2978 bytes
On 2026-10-11 05:13, Keith Thompson wrote: > > I find "break NAME;", where "NAME" is the name of an enclosing > construct, unambiguously better than "break N;", where N is the > number of levels to break out of. Yes, sure. (Reminds me Pascal that supported for 'goto' just integer numbers [in the range 1..9999, IIRC] for jumps. - This is different from 'break N' but still also a bad design, IMO. - Not sure about later Pascal dialects, though. - Numbers for labels or levels, not nice.) > > The "break N" syntax is specified by POSIX. It's supported by ksh, > bash, dash, zsh, and probably other Bourne-based shells. (My guess > is that it originated in ksh.) My best guess is that because the > Bourne-like shells don't have gotos, they don't have labels, so > named loops would have required inventing those too. And admittedly > I suppose it's not too bad if it's no more than a couple of levels -- > but it's still easy to, ahem, *break* if you reorganize the code. Yes. - But while I don't find it (the N) elegant as concept it's in practice not that bad WRT "reorganization of code" since it's (as opposed to the 'goto' in other languages) a local construct. Janis > [...]
Technical Details
Message-ID:
<11afhr4$286ml$3@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<119qf6l$2rmg3$1@dont-email.me> <11ac0mi$19kfd$1@dont-email.me> <11ac2jv$1a84t$1@dont-email.me> <11ac783$1bkuo$1@kst.eternal-september.org> <11ad5eq$1l8hg$1@dont-email.me> <11ad9fg$cjm0$4@dont-email.me> <11addhr$1oakb$1@dont-email.me> <11aduuk$cjlv$1@dont-email.me> <20261010220212.000063fd@yahoo.com> <11ae56o$cjlv$4@dont-email.me> <20261010230355.00005189@yahoo.com> <11ae7eb$cjlv$6@dont-email.me> <11aeee0$24k8m$1@kst.eternal-september.org> <11aer17$286ml$2@dont-email.me> <11aeusp$29hmu$2@kst.eternal-september.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Sun, 11 Oct 2026 10:36:52 +0200 Organization: A noiseless patient Spider Lines: 30 Message-ID: <11afhr4$286ml$3@dont-email.me> References: <119qf6l$2rmg3$1@dont-email.me> <11ac0mi$19kfd$1@dont-email.me> <11ac2jv$1a84t$1@dont-email.me> <11ac783$1bkuo$1@kst.eternal-september.org> <11ad5eq$1l8hg$1@dont-email.me> <11ad9fg$cjm0$4@dont-email.me> <11addhr$1oakb$1@dont-email.me> <11aduuk$cjlv$1@dont-email.me> <20261010220212.000063fd@yahoo.com> <11ae56o$cjlv$4@dont-email.me> <20261010230355.00005189@yahoo.com> <11ae7eb$cjlv$6@dont-email.me> <11aeee0$24k8m$1@kst.eternal-september.org> <11aer17$286ml$2@dont-email.me> <11aeusp$29hmu$2@kst.eternal-september.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 11 Oct 2026 08:36:52 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2366165"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19kiVzINFJau8c9lvIBOAtA"; posting-host="dc047fa64def26b023d01b53ecdcc125" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:fsao3ZW931L/Zl9YSparuqlhNys= sha256:B93hHqjEvvqFFr2LgFxudMVTHOQS6KbZ3LXtnsd48cg= sha1:JpmVDvVRhet+OIWs3ea9oz6iwbw= sha256:/B/5GIGN5F3Mw9n3KnhqfkqvZ2zJ/1x8WceBlind3L0= In-Reply-To: <11aeusp$29hmu$2@kst.eternal-september.org> Content-Language: en-US