Article View: comp.lang.c
Article #462Re: Taming The Switch-Statement
From: Janis Papanagnou
Date: Fri, 16 Oct 2026 23:29
Date: Fri, 16 Oct 2026 23:29
63 lines
4497 bytes
4497 bytes
On 2026-10-17 00:00, Keith Thompson wrote:
> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>[...]
>>> 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 (;;)" :
>>> [...]
>>
>> 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?
Why would one question an opinion? ;-)
>
> 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.
I've no strong opinion on that, but I find the "for NAME (;;)" to
clearer express the _local scope_ of embedded breaks or continues.
(Just a matter of taste, and my appreciation for locality.)
>
> 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.
If that sort of jump would be _restricted_ to the respective loop
then I'd not see how I'd miss that since it's closely placed. (It
might also help if, as shown above, some all-caps convention would
be applied to labels.)
>
> (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.)
Well, there were both variants, the Algol 60 "integer procedure"
and the Algol 68 "(...) INT :" (or Pascal's syntax equivalent with
a 'function' keyword, similarly, but with another syntax, in Awk).
But there's more syntactic factors that influence where the name is
located, so many variants are existing. (But we're anyway talking
just about "C", so it's all void, whatever personal preferences.)
The point with the separation of two lines is a question distinct
from the choice, unless we'd choose a syntactic variant of the two
forms, specifically "fname (parms) res_t" (i.e. without keyword).
As far as I recall, in "C", the name of the function was often put
separately (first in the line) to have an easy method to find its
declaration by simple "grep ^fname". (With any sophisticated editor
this might be a weak argument, though.)
Janis
Technical Details
Message-ID:
<11auc0s$206gh$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> <86mrsdpcgp.fsf@linuxsc.com> <11au6pr$3mdne$1@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: Sat, 17 Oct 2026 01:29:32 +0200 Organization: A noiseless patient Spider Lines: 63 Message-ID: <11auc0s$206gh$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> <86mrsdpcgp.fsf@linuxsc.com> <11au6pr$3mdne$1@kst.eternal-september.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 16 Oct 2026 23:29:33 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2103825"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Z4bNPQdz5bPnez9PgQJB1"; posting-host="363167b3e8480ec3554e817f0410423a" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:PVAd6sk9RFSSDj2tjWfV87m1eAg= sha256:GUNV1QFYCvXaWvNugsEvaMp+FwQ0Y7ta8tOkDQvdT3c= sha1:8O0lkVZNkDzDUkm/ZelDsZ97QOQ= sha256:QH3ZYe4vVkqj6N4TigLzCmRM83+ZN0gOtECE5itY2Hs= Content-Language: en-US In-Reply-To: <11au6pr$3mdne$1@kst.eternal-september.org>