🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #395

Re: Taming The Switch-Statement

#395
From: Peyton
Date: Wed, 14 Oct 2026 18:04
50 lines
2646 bytes
bart <bc@freeuk.com> writes:

> On 14/10/2026 13:38, Dan Cross wrote:
>> In article <11anobe$1dt0e$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>
>> Yes, I am aware that you will tell me that it is justified
>> because that problem is actually the one worth solving, and the
>> others are not; you needn't bother.  Simply put, I disagree that
>> that one problem is sufficiently important to warrant its own
>> solution, particularly when something more general is already
>> known and available in the language (labeled break/continue).
>
> I missed this bit.
>
> Is labeled break now available in C?
>
> If so, how would it be used here:
>
>
>    while (1) {
>        switch (x) {
>        case y:
>            Break;
>
> where that Break is meant to quit the loop.
>
> Remember that if DMR hadn't made that screw-up in 1972 it would simply
> have been as it is above with his choice of keyword in place of Break.
>
> But I would be interested in trying out the new feature.
>
>
No it's definetely not supported yet. I am very much in support of it
though. Not sure when or if. In the meantime I guess you can use the
forbidden goto like so:

while(1) {
    switch(x) {
      case 1:
        doThing();
        break;
      case 2:
        goto exitLoop;
      default:
        break;
  }
}

exitLoop;
-- 
Technical Details
Message-ID: <87zewgxip7.fsf@peyton-d>
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> <11amecs$10eab$1@dont-email.me> <11amune$ipi$1@reader2.panix.com> <11anobe$1dt0e$1@dont-email.me> <11ant3u$6o$1@reader2.panix.com> <11aoff0$1n82v$1@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: "Peyton" <peyton@solacium.com>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Wed, 14 Oct 2026 11:04:04 -0700
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <87zewgxip7.fsf@peyton-d>
References: <119qf6l$2rmg3$1@dont-email.me> <11amecs$10eab$1@dont-email.me>
	<11amune$ipi$1@reader2.panix.com> <11anobe$1dt0e$1@dont-email.me>
	<11ant3u$6o$1@reader2.panix.com> <11aoff0$1n82v$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Wed, 14 Oct 2026 18:04:15 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1789430"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/QI/81IyPTyTt0Fc7QMQvp"; posting-host="b57152c02746c88193cbd63f906b2388"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:i5jmFcCr36vtDf5OZRiD4/A/RqU=
	sha1:VW5ncnVRSqxqbf7yMHn01yHaDRU= sha256:0f6MCHRS+fsGp+Fz1vLJbE0VT4HWE5L2ccDZSrLUQwk=
	sha1:cMqrHwpskFnICnBU2Rjin7Rks4Y= sha256:2QLbS14z/k71Sa1yni89XdLyzdgLw9INuE7BxyA5VDo=