Article View: comp.lang.c
Article #553Re: Taming The Switch-Statement
From: Janis Papanagnou
Date: Mon, 19 Oct 2026 14:15
Date: Mon, 19 Oct 2026 14:15
57 lines
3799 bytes
3799 bytes
On 2026-10-19 00:18, Dan Cross wrote:
> In article <11b2pq5$3pvda$7@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>> On 2026-10-18 16:13, Michael S wrote:
>>> On Sun, 18 Oct 2026 14:34:28 +0200
>>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>>>> On 2026-10-18 14:09, David Brown wrote:
>>>>>
>>>>> [...] (I don't know why N3377 proposed "do { } while NAME ( )"
>>>>> rather than "do NAME { } while ( )". )
>>>>
>>>> Oh! - I can only think that it would then be (sort of) "consistent"
>>>> with the place of the label attacked in a 'while' loop; i.e. behind
>>>> the 'while' keyword. - It's inconsistent in another interpretation,
>>>> though; and I'd certainly have favored the latter form, to have the
>>>> label consistently attached at the loop-entry keyword.
>>>
>>> I'd prefer label consistently attached to the loop-exit keyword.
>>
>> I can see that this might look appealing in case of 'break'. In
>> case of the same mechanism working also for 'continue' I'd then
>> think that it should generally better be an "attribute" of the
>> loop entry keyword, i.e. placed where loops start. [...]
>
> I think colocating it with `do` might create a syntactic
> ambiguity. In the case of `for`, `while`, and `select`, there
> is a required token following the keyword (the `(`). However,
> for a `do`/`while` loop, `do` is followed immediately by a,
> `secondary-block` production.
Good point!
> In particular, you do not _need_
> braces to denote a compound statement after `do`; something like
> `do i++; while (i < j);` is perfectly legal in C.
Yes.
>
> In the N3377 proposal, the new `block-name` is just an
> identifier. If it were allowed immediately after the `do`, then
> given, `do NAME statement; while(condition);` you can't tell
> `NAME` from the name of the loop and a random identifier before
> a statement; something like `do LOOP i++; while (i < j);`
> appears as though it _would_ be be syntactically valid by N3377
> as presently worked, but is the programmer's intent to create a
> loop name, or should this just be a syntax error?
>
> By requiring the block-name between a keyword and a
> syntactically required `(`, you remove that ambiguity: if there
> is an identifier there, then it is a `block-name`; if not, then
> the block has no name.
Thanks for your elaborations.
Janis
Technical Details
Message-ID:
<11b58md$1kr9u$4@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> <11b2eck$3pvd9$1@dont-email.me> <20261018171339.00005308@yahoo.com> <11b2pq5$3pvda$7@dont-email.me> <11b3gkj$mt2$1@reader2.panix.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: Janis Papanagnou <janis_papanagnou+ng@hotmail.com> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Mon, 19 Oct 2026 16:15:41 +0200 Organization: A noiseless patient Spider Lines: 57 Message-ID: <11b58md$1kr9u$4@dont-email.me> References: <119qf6l$2rmg3$1@dont-email.me> <11b2eck$3pvd9$1@dont-email.me> <20261018171339.00005308@yahoo.com> <11b2pq5$3pvda$7@dont-email.me> <11b3gkj$mt2$1@reader2.panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 19 Oct 2026 14:15:41 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1731902"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cPv6Mg7dqa5lO4F+4YKy1"; posting-host="9a1787de1638a6d9f83c958712c1b12a" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:+Onu2o7V87vmWERzxgkwTndhXcg= sha256:K7GzcGJmeisnMGcM07AfoZjAaadDz7ZP0tiyahPH59M= sha1:cg9UsVB4iaion14jSNzdqUqWGvQ= sha256:N/NT3e21xxasjNUWl8/QYb/hMDfDI+Z2KEAIVbKLZ6U= In-Reply-To: <11b3gkj$mt2$1@reader2.panix.com> Content-Language: en-US