🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #169

Re: Taming The Switch-Statement

#169
From: Janis Papanagnou
Date: Sun, 11 Oct 2026 02:07
39 lines
3190 bytes
On 2026-10-11 00:32, Keith Thompson wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>> 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. - I suppose, you needed to used a 'goto' instead
>> (and avoid the 'break' completely for those cases).
> 
> Something like that, sure, but please not that.
> 
> Specifying the *number* of levels to break or continue is IMHO
> horrible.  "break N" makes me count things so the computer doesn't
> have to.

I agree; that's what I also dislike about it.

The point is the question what choices you have. The 'goto' is IMO
the worst; because of semantic interdependencies that will regularly
lead to semantical restrictions about its applicability (or placement
of labels); various languages have various restrictions, it's just
a mess! The 'break' is a "cheap" solution, but also very restricted.
There's yet other variants with their own drawbacks; I won't even
start with it.

> 
> There are proposals, and precedents in other languages, for *named*
> loops, and I'd like to see that in a future C.

One of the better possibilities, maybe; but still not satisfying for
my (very subjective) taste.

(Some language let you organize such things in completely other ways
with no need for jumps of any sort.)

Janis
Technical Details
Message-ID: <11aer17$286ml$2@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> <11aeee0$24k8m$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: Sun, 11 Oct 2026 04:07:35 +0200
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <11aer17$286ml$2@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 11 Oct 2026 02:07:35 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2366165"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+xYp7DUB/90hqshkk0K698"; posting-host="dc047fa64def26b023d01b53ecdcc125"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:NC4otQ4mWTd5K7zjJl1hzZ8tSzg= sha256:OLNed0jJ0Bvvv34S3H7Pio6NgjKOy8NZXsZ3hJIrSvw=
	sha1:3MvbSsbwuEYjZDTYnelR2k+o6Yw= sha256:JABTb8MGpif2whc/XmAzaoyuwESSF6Zo5SjBy64uJ9U=
Content-Language: en-US
In-Reply-To: <11aeee0$24k8m$1@kst.eternal-september.org>