Article View: comp.lang.c
Article #401Re: Taming The Switch-Statement
From: Michael S
Date: Wed, 14 Oct 2026 20:28
Date: Wed, 14 Oct 2026 20:28
42 lines
2666 bytes
2666 bytes
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...
}
Technical Details
Message-ID:
<20261014232810.0000352a@yahoo.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> <11anobe$1dt0e$1@dont-email.me> <11ant3u$6o$1@reader2.panix.com> <11ao8af$1k8p3$1@dont-email.me> <11aol8k$adq$1@reader2.panix.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: Michael S <already5chosen@yahoo.com> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Wed, 14 Oct 2026 23:28:10 +0300 Organization: A noiseless patient Spider Lines: 42 Message-ID: <20261014232810.0000352a@yahoo.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> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Date: Wed, 14 Oct 2026 20:28:15 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1850509"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Q07Z9aJZHoKvCVWWQF+nMp1wSQvnWd5c="; posting-host="d1ba7bf97adb8bc618bab6b329bfe8d1" Cancel-Lock: sha1:4UsT2dS7ZIcL1ziR9SkI/4cTpcc= sha256:6hOlhQmvps+QqHuv28E5QUquz6hwtv+WXh8lAAvgwwA= sha1:IO2kbp1yjkH2dxFvMV67INf/fHk= sha256:0AeycAngLct20MTlp/3o/9hQTy9aPbEsg8neoRcS/C8= X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)