Article View: comp.lang.c
Article #159Re: Taming The Switch-Statement
From: bart
Date: Sun, 11 Oct 2026 00:43
Date: Sun, 11 Oct 2026 00:43
43 lines
3295 bytes
3295 bytes
On 10/10/2026 23:58, Michael S wrote: > On Sat, 10 Oct 2026 15:32:32 -0700 > Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: > >> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: >>> On 2026-10-10 22:03, Michael S wrote: >>>> The cases where I want to break out of the loop from the switch in >>>> the >>>> body of the loop are very common. >>> >>> Ah, so you'd have needed something like Kornshell's 'break 2' to >>> leave more than one level. - I suppose, you needed to used a 'goto' >>> instead (and avoid the 'break' completely for those cases). >> >> Something like that, sure, but please not that. >> >> Specifying the *number* of levels to break or continue is IMHO >> horrible. "break N" makes me count things so the computer doesn't >> have to. >> >> There are proposals, and precedents in other languages, for *named* >> loops, and I'd like to see that in a future C. >> > > Yes. Break n is a maintanance nightmare. I use numbered loops (in my syntaxes). At the same time, I don't, since breaking across nested versions is uncommon. But when needed, then invariably it will be the outermost loop, which also has the loop index '0', which be written 'all'. > Ada syntax (optional label before loop) is a lot better. Actually it makes little difference, maintenance-wise. Both absolute references to loops (labels) and relative references (indices) have complementary set of problems, when loops are added or inserted or removed. But as I said the most common requirement IME is to break out of either the current loop, or the whole lot.
Technical Details
Message-ID:
<11aem49$27di1$1@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> <20261011015833.00004d29@yahoo.com>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: bart <bc@freeuk.com> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Sun, 11 Oct 2026 01:43:54 +0100 Organization: A noiseless patient Spider Lines: 43 Message-ID: <11aem49$27di1$1@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> <20261011015833.00004d29@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 11 Oct 2026 00:43:54 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2340417"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+udoO8g88f0ElTUP85BZ4Z"; posting-host="bb4c63ed27c528dcfc498e66a186f254" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:CgB/IXbAZps+CuKrPP8t0ETjlrY= sha256:RsCSj+7YVZqNY1/PYslA0un3xAg0zaavKVTSczsyNhE= sha1:E8Oilj4EMq876Ob2W5u0hjHd/Jk= sha256:j+QGGikPWk5yiSWo6I5IwU+c0L8cc+jK29ZfQGY4wfQ= In-Reply-To: <20261011015833.00004d29@yahoo.com> Content-Language: en-GB