🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #105

Re: Taming The Switch-Statement

#105
From: Janis Papanagnou
Date: Sat, 10 Oct 2026 12:01
52 lines
3777 bytes
On 2026-10-10 12:53, bart wrote:
> On 10/10/2026 03:17, Keith Thompson wrote:
[...]
>> Yes, you have to remember to write "break;" at the end of each case.
>>
>> I haven't seen any proposals to add such a feature -- probably
>> because nobody else is as angry about it as you are.
> 
> I'm angry because it was SO EASY to get right in the first place 
> (Algol68 and Pascal already existed), and nearly as easy to fix even 
> within the intervening decades.

The C-folks had other design criteria than the Pascal or Algol 68
people; the latter two have also fundamental different concepts in
their respective language (also concerning their 'case' construct).
(Specifically the Algol 68 'case' isn't very progressive, being
restricted to - even implicit! - integer tags from 1 to some N.)

I think the problem with your statement is also that you think your
preferred construct is the only one that is "right". (You seem to
be confident that supporting "fall-though" is generally "wrong".)
Just imagine if some C-programmers wanted a fall-through semantics
but all they got would be the Pascal or Algol 68 'case' construct.

I also want to remind Kornshell's break/fall-though options in their
'case', not as bulky as 'break' but yet more punctuation characters
(that makes it, if not somewhat cryptic, at least easy to overlook).

(I'm using both options, in Shell and in "C". And I cannot do that
[as simply as in "C"] in Pascal or Algol 68, where I then [have to]
use other code patterns.)

Whichever language; they have design principles. Buy them or switch.
(Unintended "switch" pun.)

You may blame the respective language if you have problems with it.
But I have a general (and well meant) suggestion for you...
If you notice that you are doing specific mistakes repeatedly - and
where you cannot change "the environment" of your mistake! - train
your awareness! (That's more successful a strategy than persistent
whining about it; i.e. if you're interested to get your tasks done.)

Janis

PS (disclaimer): That all said, I still think the approach in "C" is
a low level pattern. In other programming language I'm using their
respective patterns within their language design principles. - Some
minimum mental _flexibility_ is certainly required from programmers
if they want to (or have to) use different types of languages.

> [...]
Technical Details
Message-ID: <11ad9fg$cjm0$4@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>

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: Sat, 10 Oct 2026 14:01:52 +0200
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <11ad9fg$cjm0$4@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 10 Oct 2026 12:01:53 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="413376"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18cHDefB/kGe2HeuEojc4LE"; posting-host="51a9598490edb80150aa60ca9e0cee6b"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ptq1Pvscca5eklAqc/81nu57Ijc= sha256:5xkiYDVsh1LMAw9ZVFRSSvsbjJigAPwwsRPMisXOcCk=
	sha1:HbM3nMPBGLg0jzPCgC3GBhqBWGI= sha256:FGk8X2SXtehDTMu3uWa+tin2GMXpBX68EACXYU8e0/E=
In-Reply-To: <11ad5eq$1l8hg$1@dont-email.me>
Content-Language: en-US