Article View: comp.lang.c
Article #466Re: Taming The Switch-Statement
From: Kenny McCormack
Date: Sat, 17 Oct 2026 11:09
Date: Sat, 17 Oct 2026 11:09
47 lines
3010 bytes
3010 bytes
In article <11audde$3oci5$1@kst.eternal-september.org>,
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>bart <bc@freeuk.com> writes:
>[...]
>> What's often stated also is how successful C has been, but that
>> doesn't magically make the syntax wonderful.
>
>NOBODY THINKS C'S SYNTAX IS WONDERFUL.
The funny thing is: I actually do.
I may be the only person here who actually thinks the syntax of C's
"switch" statement is just fine. Once you realize that it *is* more of a
computed goto rather than a high level alternation construct like you'd
find in a real high level language (C is *not* a high level language; it is
properly referred to as a "mid level" language).
Note that the underlying issue here is easily dealt with if you do both of
the following:
a) Enable the warning in your compiler that warns about (unannotated)
fallthrough.
and
b) Always put a comment when you intentionally do fallthrough.
This issue is kind of similar to the old:
if (a = b) ...
thing - which really was a problem - right up until compilers started
warning about it. Now that all compilers warn if you do that, it is no
longer a live issue, but people still bring it up occasionally.
FWIW, to take another popular whipping boy of C, I also actually like the
variable declaration syntax - which many people like to criticize as
"backwards" or "inside out". Once you get used to it, it makes perfect
sense (to me, anyway). I have no problem with a declaration like:
int i,j,*ip,arr[10],foo(int bar);
Some would say that declares lots of different types of objects, but I
think of them all as ints (which is what the declaration is telling us).
--
The randomly chosen signature file that would have appeared here is more than 4-ish
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/Seneca
Technical Details
Message-ID:
<11avl11$poq2$1@news.xmission.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!weretis.net!feeder9.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mailReferences:
<119qf6l$2rmg3$1@dont-email.me> <11at5vi$5vu$1@reader2.panix.com> <11auad0$3no1k$1@dont-email.me> <11audde$3oci5$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!weretis.net!feeder9.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail From: gazelle@shell.xmission.com (Kenny McCormack) Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Sat, 17 Oct 2026 11:09:21 -0000 (UTC) Organization: The official candy of the new Millennium Message-ID: <11avl11$poq2$1@news.xmission.com> References: <119qf6l$2rmg3$1@dont-email.me> <11at5vi$5vu$1@reader2.panix.com> <11auad0$3no1k$1@dont-email.me> <11audde$3oci5$1@kst.eternal-september.org> Injection-Date: Sat, 17 Oct 2026 11:09:21 -0000 (UTC) Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4"; logging-data="844610"; mail-complaints-to="abuse@xmission.com" X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: gazelle@shell.xmission.com (Kenny McCormack)