Article View: comp.lang.c
Article #458Re: Taming The Switch-Statement
From: Keith Thompson
Date: Fri, 16 Oct 2026 22:00
Date: Fri, 16 Oct 2026 22:00
40 lines
3359 bytes
3359 bytes
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> 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. [...]
>
> Definitely.
>
>> There's a proposal for C2y to use goto labels as loop names, and a
>> competing one to define a new syntax like "for NAME (;;)" :
>>
>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3377.pdf
>
> I'm not particularly a fan of multi-level break/continue. But if
> we're going to have one of these, the second ("for NAME (;;)") is
> unquestionably better.
Unquestionably? Why?
I do like the fact that it doesn't conflate goto labels with loop
names, but I still prefer the "NAME: for (;;)" form, partly because
it's consistent with several other languages.
One minor drawback, IMHO, is that the name is easier to miss, because
it's not at the beginning of the line. This is based on zero experience
using it.
(The same problem exists with function names. Personally, I just
tolerate that rather than using the common convention of splitting the
return type and function name across two lines. I think I would have
preferred a syntax that puts the function name first, but I wouldn't
suggest changing it. I mildly dislike the convention of writing
int
func(void)
for reasons that are vague enough that I won't go into them.)
--
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:
<11au6pr$3mdne$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> <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> <86mrsdpcgp.fsf@linuxsc.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!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: Fri, 16 Oct 2026 15:00:27 -0700 Organization: None to speak of Lines: 40 Message-ID: <11au6pr$3mdne$1@kst.eternal-september.org> 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> <86mrsdpcgp.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Fri, 16 Oct 2026 22:00:27 +0000 (UTC) Injection-Info: kst.eternal-september.org; logging-data="3880686"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rhz6zqH0pC0L+QdQU4GnG"; posting-host="cf7ed1e612447f7784dc01a34361c57c" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:zukZRFpK1I0fJTVdR+2BQxiQk8w= sha256:Jm9dYN5/trSPjqceU2mMVds44sT1MzPrgfA547n1U2U= sha1:0BZc0Di0WTj5Y5NkPRtFh96IU9M= sha256:o17GwhEI0iAIHIwvrUzpyyr6OQTK0x7QaUfi6YEgiGo=