🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #331

Re: Taming The Switch-Statement

#331
From: bart
Date: Tue, 13 Oct 2026 12:41
96 lines
6028 bytes
On 13/10/2026 12:33, Janis Papanagnou wrote:
> On 2026-10-13 12:26, bart wrote:
>> On 13/10/2026 11:12, Janis Papanagnou wrote:
>>> [...]
>>> I'm aware that one might wants to pass and process two values
>>> from a function (as I interpreted one of bart's recent code
>>> fragments), but then, and if it would be "impossible" to avoid
>>> that pattern, I'd just add a condition
>>>
>>>    int leaving = 0;
>>>    while ((token = parse (&token...)) != ERROR  &&  !leaving)
>>>      switch (token)
>>>        case END_TOKEN: leaving = 1; ...
> 
> I just wrote that down without thinking, so I take the opportunity
> to correct that. In practice you would better swap the conditions
> and name the return code variable correctly
> 
>    while (!leaving  &&  (rc = parse (&token...)) != ERROR)

So your workaround had an error. That's what happens.

>>>
>>> that's really trivial and straightforward, and it's beyond me
>>> why anyone (but bart, of course) would see a problem here.
>>
>> Because it's a hack.
> 
> Your "definitions" are generally very peculiar, and they regularly
> have been considered here to not reflect what typical sane people
> would say about standard code patterns and programming. - I can
> only explain your personal valuation if I assume that your thinking
> is working in an extremely narrow corridor.

Jesus. I take it that you don't agree it is a hack then?

(From Google AI: "In coding, a hack can mean a quick, inelegant 
workaround to fix a problem". Other definitions are given, but this what 
I have in mind.)

>> But if this is acceptable, then why does C even have loop-break? Since 
>> there is always some workaround (or 'writing code' as David Brown puts 
>> it.)
> 
> This has already been explained so often, implicitly and explicitly,
> that I don't know why you're asking it again and again. - Are you
> really interested to hear all that again?! - Your perception and
> comprehension appears to be like a human /dev/null. - Okay, again...

Just answering my question would be fewer words!


> There are two principal and common "operation modes" with branches
> of switch-like constructs; to leave after the the tagged commands
> have been processed or to continue with the subsequent commands
> ("fall-through"). Various (also historic) languages do not support
> a fall-through but have even more limits on their counterpart of
> switch. The "C" designers decided to support both. Being a low-level
> language they designed it with primitive semantics but to allow full
> expressive flexibility. There are a few options how to distinguish
> the switch "operation-modes". Some languages indicated both cases
> (Kornshell, for example with ';;' and ';&' respectively). "C" has
> decided to indicate syntactically just one of the cases explicitly,
> _the case when the linear control flow is disrupted_; that thought
> makes also sense since it matches the other possible "jumps", that
> are existing with 'continue', 'return', 'exit()', 'goto'.

You have a peculiar, dense, machine-like writing style. I'm fairly 
certain you are a real human, but this is impenetrable, sorry.

> This should (again) explain what you asked with your question. (But
> we also know that you aren't really interested in the answer; your
> questions are obviously and mostly just your expression of "I don't
> like the situation with C".)
> 
>>
>> What would be the consequences of C not having it: would they be 
>> positive or negative overall?
> 
> Before I "met" you, bart, I would have guessed that any other
> choice of implementation of 'switch' in "C" would not have made
> and significant difference. Now I'd say, if the design would have
> been different then it would be much better, since then we could
> spare us all the pointless posts with you. (But of course you'd
> then find other complaints and in practice nothing would change
> anyway.)

If you aren't going to engage, why bother posting?

> PS: Note that I usually completely skip your posts

And I usually don't bother replying to yours since all you do is 
personal insults, when I can understand what you're on about.


Technical Details
Message-ID: <11al8uc$hk7a$1@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> <20261010220212.000063fd@yahoo.com> <11ae56o$cjlv$4@dont-email.me> <20261010230355.00005189@yahoo.com> <864iesjx6e.fsf@linuxsc.com> <11afvqt$2kloc$1@dont-email.me> <11ag37o$2ln0a$1@dont-email.me> <11agbsh$2pbk7$1@dont-email.me> <11aggaq$2qqh9$1@dont-email.me> <11agils$2s3tg$1@dont-email.me> <11agv1t$30q22$2@kst.eternal-september.org> <20261012220256.00003d07@yahoo.com> <11ajb95$3t8jj$1@dont-email.me> <20261012223144.00000f95@yahoo.com> <11akm9q$29tpl$1@paganini.bofh.team> <11al05t$4o6l$1@dont-email.me> <11al10u$eiet$1@dont-email.me> <11al4u0$4o6m$3@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: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Tue, 13 Oct 2026 13:41:49 +0100
Organization: A noiseless patient Spider
Lines: 96
Message-ID: <11al8uc$hk7a$1@dont-email.me>
References: <119qf6l$2rmg3$1@dont-email.me>
 <20261010220212.000063fd@yahoo.com> <11ae56o$cjlv$4@dont-email.me>
 <20261010230355.00005189@yahoo.com> <864iesjx6e.fsf@linuxsc.com>
 <11afvqt$2kloc$1@dont-email.me> <11ag37o$2ln0a$1@dont-email.me>
 <11agbsh$2pbk7$1@dont-email.me> <11aggaq$2qqh9$1@dont-email.me>
 <11agils$2s3tg$1@dont-email.me> <11agv1t$30q22$2@kst.eternal-september.org>
 <20261012220256.00003d07@yahoo.com> <11ajb95$3t8jj$1@dont-email.me>
 <20261012223144.00000f95@yahoo.com> <11akm9q$29tpl$1@paganini.bofh.team>
 <11al05t$4o6l$1@dont-email.me> <11al10u$eiet$1@dont-email.me>
 <11al4u0$4o6m$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 13 Oct 2026 12:41:49 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="577770"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+55vEsVnCu2vAT9yppvmx2"; posting-host="a4fe58cca8661e75894507eaca96fb60"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:OiHrh/btoumbyKV81aH6HcTz39I= sha256:w8StOVz3D8VGRCRp10rv/IP6KVg5Ok6yRdZBkwYj44c=
	sha1:7t6SmLIVda74HTnPZxFttg6IMaE= sha256:3k1TxY0g4Sdz/58Z/7+ISFntSDlCywx4L58LgHxwq1Y=
In-Reply-To: <11al4u0$4o6m$3@dont-email.me>
Content-Language: en-GB