🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #150

Re: Taming The Switch-Statement

#150
From: Andrey Tarasevich
Date: Sat, 10 Oct 2026 22:30
22 lines
2562 bytes
On Sat 10/10/2026 1:33 PM, Janis Papanagnou wrote:
> On 2026-10-10 22:03, Michael S wrote:
>>
>> The cases where I want to break out of the loop from the switch in the
>> body of the loop are very common.
> 
> Ah, so you'd have needed something like Kornshell's 'break 2' to leave
> more than one level.
Yes, but that would be rather inelegant in the overall scheme of things 
in C, since once we start talking about `break 2` it would be logical to 
consider `continue 2` as well (i.e. like Kornshell's `continue`).

But `break` and `continue` behave differently inside `switch` in C: the 
former can "see" the enveloping `switch` statements, while for the 
latter all enveloping `switch` statements are completely transparent. 
So, in order to refer to the same cycle one'd have to use different 
nesting numbers in `break` and `continue` when used inside `switch`(-es) 
in C. That would look quite confusing.

-- 
Best regards,
Andrey
Technical Details
Message-ID: <11aeeau$24vgh$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-mail
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>

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: Andrey Tarasevich <noone@noone.net>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Sat, 10 Oct 2026 15:30:54 -0700
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <11aeeau$24vgh$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 10 Oct 2026 22:30:55 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2260497"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX192jjRyem7TiZPsOmZeM6Df"; posting-host="7f801c3fa9925236b461fc62787bea44"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:7ADRgaLVH+YW0p2wWbGNnA1/+Vw= sha256:RYu2o2KYzBX83vqoelHOwz7QRCZRnWgsZ4/1RXGH0Pc=
	sha1:KqNnHlcp10Ldf/kNSNoavreU/AY= sha256:UPtKei62ewlGXPTtpCOAnE0Yuio3xyxrKSCR5KOOrUw=
Content-Language: en-US
In-Reply-To: <11ae7eb$cjlv$6@dont-email.me>