🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #410

Re: Taming The Switch-Statement

#410
From: Tim Rentsch
Date: Thu, 15 Oct 2026 04:30
49 lines
2870 bytes
Michael S <already5chosen@yahoo.com> writes:

> On Wed, 14 Oct 2026 19:30:28 -0000 (UTC)
> cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>
>> In article <11ao8af$1k8p3$1@dont-email.me>, bart  <bc@freeuk.com>
>> wrote:
>>
>>> On 14/10/2026 13:38, Dan Cross wrote:
>>>
>>>> In article <11anobe$1dt0e$1@dont-email.me>, bart  <bc@freeuk.com>
>>>> wrote:
>>>>
>>>>> I'd even suggest that using distinct keywords in the original C
>>>>> compiler would have made it a tiny bit simpler.)
>>>>
>>>> Unlikely.  I'm trying to chase down the citation, but it was
>>>> known that getting B to fit on the PDP-7 was a challenge.  From
>>>> the C history paper,
>>>
>>> Perhaps Switch should have been left out then if it was that tight.
>>
>> Why?  It's genuinely useful.
>
> C switch is in the middle between low level construct (computed goto)
> and higher level select/case/whatever of many other languages.
> I suppose that implementing true low level alternative would have been
> simpler for compiler.  And it would be even more powerful than current
> construct.  Of course, also more dangerous, but being dangerous is not
> against C philosophy.
>
> int foo()
> {
>   ...
>   case 42:
>   ....
>   switch(bar(x)); // can go not just to 6 and 7, but to 42 as well.
>   // if there is no 'default:' in the scope then default ends up here
>   ....
>   case 6:
>   ...
>   case 7:
>   etc...
>
> }

I'm reminded of a quote from E.W. Dijkstra:

"No, gentlemen.  Three times no."
Technical Details
Message-ID: <86o6cvr3g4.fsf@linuxsc.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-mail
References: <119qf6l$2rmg3$1@dont-email.me> <11anobe$1dt0e$1@dont-email.me> <11ant3u$6o$1@reader2.panix.com> <11ao8af$1k8p3$1@dont-email.me> <11aol8k$adq$1@reader2.panix.com> <20261014232810.0000352a@yahoo.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: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Wed, 14 Oct 2026 21:30:03 -0700
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <86o6cvr3g4.fsf@linuxsc.com>
References: <119qf6l$2rmg3$1@dont-email.me> <11anobe$1dt0e$1@dont-email.me> <11ant3u$6o$1@reader2.panix.com> <11ao8af$1k8p3$1@dont-email.me> <11aol8k$adq$1@reader2.panix.com> <20261014232810.0000352a@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Thu, 15 Oct 2026 04:30:06 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2185445"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/0EZdxpnBY5ir/HMszh6jhw2vDkulwOzo="; posting-host="8e248dd53a94b2a901695ff9f1057f0e"
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:cKBcm8fpgmQSenijhNrIvw8mfXE=
	sha1:+0g7mqwltZGwJ6Q644gli91hDTE= sha256:sZlgBNKjfc3m/8bnYnzvapiJ0sA01DsUbRWzy1AR8b4=
	sha1:piZKX3dG5U2SAVkKtgzZXSgvELg= sha256:9pQv86GN4UnVgdtBPCI6ouhBnR5aMAzaWZZbQ2BdviI=