Article View: comp.lang.c
Article #402Re: Taming The Switch-Statement
From: Keith Thompson
Date: Wed, 14 Oct 2026 20:58
Date: Wed, 14 Oct 2026 20:58
51 lines
3157 bytes
3157 bytes
bart <bc@freeuk.com> writes:
> On 14/10/2026 13:38, Dan Cross wrote:
>> In article <11anobe$1dt0e$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>
>> Yes, I am aware that you will tell me that it is justified
>> because that problem is actually the one worth solving, and the
>> others are not; you needn't bother. Simply put, I disagree that
>> that one problem is sufficiently important to warrant its own
>> solution, particularly when something more general is already
>> known and available in the language (labeled break/continue).
>
> I missed this bit.
How?? I've mentioned it more than once in this thread.
> Is labeled break now available in C?
It's proposed for C2y, and implemented as an extension in gcc and clang.
The latest C2y draft is
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3886.pdf
6.8.2 describes named iteration and switch statements.
6.8.7.3 and 6.8.7.4 describe the "continue" and "break" statements.
> If so, how would it be used here:
>
> while (1) {
> switch (x) {
> case y:
> Break;
>
> where that Break is meant to quit the loop.
I have no doubt that you can figure it out after reading the cited
sections. (I'm not sure why you spelled "break" with an uppercase 'B'.)
[...]
Elsewhere, you've mentioned that labels have function scope.
That's not a problem. A named "break" or "continue" can only
refer to the label of an enclosing iteration or switch statement.
"break FOO;" where FOO does not apply to an enclosing loop or switch
is a constraint violation. But "goto FOO;" is valid as long as
"FOO:" is within the same function (with some restrictions that
aren't relevant here).
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Technical Details
Message-ID:
<11aoqed$1qib2$1@kst.eternal-september.org>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!kst.eternal-september.org!.POSTED!not-for-mailReferences:
<119qf6l$2rmg3$1@dont-email.me> <11amecs$10eab$1@dont-email.me> <11amune$ipi$1@reader2.panix.com> <11anobe$1dt0e$1@dont-email.me> <11ant3u$6o$1@reader2.panix.com> <11aoff0$1n82v$1@dont-email.me>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!kst.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Wed, 14 Oct 2026 13:58:53 -0700 Organization: None to speak of Lines: 51 Message-ID: <11aoqed$1qib2$1@kst.eternal-september.org> References: <119qf6l$2rmg3$1@dont-email.me> <11amecs$10eab$1@dont-email.me> <11amune$ipi$1@reader2.panix.com> <11anobe$1dt0e$1@dont-email.me> <11ant3u$6o$1@reader2.panix.com> <11aoff0$1n82v$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 14 Oct 2026 20:58:54 +0000 (UTC) Injection-Info: kst.eternal-september.org; logging-data="1919330"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GVQ1OhZQB8HtG+68Z1eaY"; posting-host="8bc08a5e85dad83e60fe86919d5c20fb" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:bJFYyVA3+8ds82OkvcVQAGARy50= sha256:h6YgejxTbT6+pzKQWa32K5yvnkGMulzR79yj9PbwAHg= sha1:xLs5aLRhpSzcb//UzuiUvKAFXCc= sha256:7k8gfUAEponD2O1klvCWOqblbhPVIUzc6Hs4rEHYDlw=