Article View: comp.lang.c
Article #487Re: Taming The Switch-Statement
From: bart
Date: Sun, 18 Oct 2026 11:04
Date: Sun, 18 Oct 2026 11:04
47 lines
3653 bytes
3653 bytes
On 18/10/2026 11:48, David Brown wrote:
> On 17/10/2026 01:29, Janis Papanagnou wrote:
>> 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.)
>>
>
> A main objection to "name: for ..." is that with function-scope labels,
> you need a new name for every labelled loop or switch. That may be an
> inconvenience, especially for macro with labelled loops, or for copy-
> and-paste code. There is a proposal to deal with that which basically
> says :
>
> 1. Any "break label;" or "continue label;" refers to the innermost
> containing loop or switch with that label.
>
> 2. Any "label" used in "goto label;" must be unique in the function.
>
> Those rules give a simple and intuitive fix without affecting existing
> code.
There's something missing. Labels usually live in their own,
function-wide name space.
But if you have two loops like this:
L1: while () {} L2:
L1: while () {} L2:
Then even if no gotos exist to L1, is that rule somehow relaxed for
those L1s to allow them to co-exist? (While still applying to non-loop
labels L2, which would clash.)
Will the L1s still live within the regular name space? (Presumably each
will now be tagged with its associated loop.)
> Beyond that, "name: for ..." or "for name ..." is, as you say, mostly a
> matter of taste. (There are proposals for both versions, and you can
> look them up to see the arguments.)
The second form allows for those label names to be special, for example
by belonging in the same name space as regular identifiers and thus
subject to block scope rules. This is a tidier solution to the above.
Technical Details
Message-ID:
<11b293j$12jfa$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> <11aer17$286ml$2@dont-email.me> <11aeusp$29hmu$2@kst.eternal-september.org> <86mrsdpcgp.fsf@linuxsc.com> <11au6pr$3mdne$1@kst.eternal-september.org> <11auc0s$206gh$3@dont-email.me> <11b285v$121v2$2@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!.POSTED!not-for-mail From: bart <bc@freeuk.com> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Sun, 18 Oct 2026 12:04:18 +0100 Organization: A noiseless patient Spider Lines: 47 Message-ID: <11b293j$12jfa$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> <11aer17$286ml$2@dont-email.me> <11aeusp$29hmu$2@kst.eternal-september.org> <86mrsdpcgp.fsf@linuxsc.com> <11au6pr$3mdne$1@kst.eternal-september.org> <11auc0s$206gh$3@dont-email.me> <11b285v$121v2$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 18 Oct 2026 11:04:19 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1134058"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+q/wz9IY7jmsywUAXoEt/X"; posting-host="c99c9a957370eff0b06f081ccfe4e16c" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:zD0bYeSKRw5RyQVJM1U+oXyzF3w= sha256:axqDVoV9MgIXcL9Soq8xzOad9J0SjFa6xoCOMW/3yjU= sha1:EIwyr5A0z6dDhHctVLPTDs2ypT8= sha256:mPxqjeMc+v9cl7OLo3NDPd+VncNtPl8meKDgvikF30M= Content-Language: en-GB In-Reply-To: <11b285v$121v2$2@dont-email.me>