Article View: comp.lang.c
Article #1232Re: Taming The Switch-Statement
From: Rosario19
Date: Sun, 01 Nov 2026 09:13
Date: Sun, 01 Nov 2026 09:13
89 lines
5088 bytes
5088 bytes
On Sun, 18 Oct 2026 23:51:25 -0000 (UTC), (Waldek Hebisch) wrote:
>Dan Cross <> wrote:
>> In article <>,
>> Janis Papanagnou <> wrote:
>>>On 2026-10-18 16:13, Michael S wrote:
>>>> On Sun, 18 Oct 2026 14:34:28 +0200
>>>> Janis Papanagnou <> 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. (But that's
>>>just my opinion.) Having it at a different place with a do-loop
>>>I consider a really bad decision. It's advantageous to know the
>>>direction in which to seek for the label if you inspect code. -
>>>But okay, it's "C"; I won't heat up about some future C-release
>>>that I'll never use (especially given that I'm not even be using
>>>all of those more recent additions that are already available).
>>
>> 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. 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.
>>
>> 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.
>
>AFAICS this is worse, both:
>
>do (i++); while (i < j);
>
>and
>
>do LOOP(i++); while (i < j);
>
>are currently legal (assuming that 'LOOP' is a function).
>
>Writing statement with parentheses may look silly, but such code
>may be easily produced due to use of macros.
I think for(;;) loop is good because one clear see where are the
initialization part of variable of the loop, the instruction that
break the loop, the change ciclical of variables of the loop
If not so, it is easy emulate the loop in this way
Inizializations
Label: Increment or change varaibles of the loop
Instruction for exit the loop
Instructions
goto label;
It due my ignorance of C, I not see all these problem on all this
LoopName for me is easy that is a label
the position of label is inside the {}
as
for(Ini();f();Inc())
{LoopName:
...
if(cond) break LoopName; // would mean just if(cond) goto LoopName;
}
Technical Details
Message-ID:
<0gvdell6lp924u0h8qt3aulubc89tfndfl@4ax.com>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> <11b3m1r$3tp6p$1@paganini.bofh.team>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: Rosario19 <Ros@invalid.invalid> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Sun, 01 Nov 2026 10:13:44 +0100 Organization: A noiseless patient Spider Lines: 89 Message-ID: <0gvdell6lp924u0h8qt3aulubc89tfndfl@4ax.com> 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> <11b3m1r$3tp6p$1@paganini.bofh.team> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 01 Nov 2026 09:05:47 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1930709"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SRMxgBz8RSJdLWFK4LtCsSLLaz3kJM+o="; posting-host="35da1d5d5686e3d22afe7b844cfd8830" Cancel-Lock: sha1:EZO9NSGIT0yvGn0l794ohtD7mRY= sha256:9/15kJdMmvSSlDTcGBoi5jvtuo2C0gw//pSsEoQj4vM= sha1:S+z+iTKzVlVChT2DQp/MxZevnYE= sha256:S7SbOtWE98Kyc+kf35u0+nHcVvXXUeXmIvHAeYMh5eI= X-Newsreader: Forte Free Agent 1.93/32.576 English (American)