🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #671

Re: Taming The Switch-Statement

#671
From: fir
Date: Thu, 22 Oct 2026 07:51
69 lines
3352 bytes
Blaine pisze:
> fir wrote:
>> Lawrence D’Oliveiro pisze:
>>> t to end each case-sequence in a switch statement with
>>> a break-statement: put the break at the same indentation level as the
>>> case-clause as well as the switch-expression. That way, you can scan
>>> your eye down a single line f
>>
>> some time ago i was saying what the proper switch should like
>> (imo, but im not sure if my conclusions are anough to take is a s proven)
>>
>> case {} case {}  case {} otherwise {}
>>
>> its indeed sorta needed becouse case in fact are ifs
>> (not if-elses)  (so some in fact could write
>>
>> if {} if {} if {} otherwise {}
>>
>> its the same)
>>
>>   the problem is you  got no group alse
>> and here this otherwise need to check all ifs
>> "or" them and use group else for them
>>
>> this could be written in few ways, but my case case case otherwise 
>> names it
>> could also do
>>
>>
>> if {} or if {} or if {} else {}
>>
>> so either you need logic operators here or predefined constructs like 
>> otherwise (maybe both)
>>
>> and that should be included not switch wchich is bad imo
>>
>>
>> other way is to define distionary more as data construct
>>
>> dict {
>> 'mental'  {/* 1 */}
>> 'reductionists' {/* 2 */}
>> 'suck' {/* 3 */}
>> }
>>
>> then you could use
>>
>> dict('reductionists')
>>
>> to yeld to  /* 2 */
>>
>> this second one parallels to switch keyword
>>
>>
>> so c switch mixes them both in bad way..they should be spitet and 
>> upbuild as showed ;c
>>
>> thats my conclusion as switch topic as far by now ;c
>>
> Just start using the switch statement. It's useful in very very very 
> many cases. You'll get the hang of it right away. Next, it doesn't just 
> test variable type 'int', also notably 'char', among others.
> 
how do you know i dont use it?


in fact i dont use it its not logical (as roven above) yet looks ugly

(im not using parts of c quite happily especily switch and macros
Technical Details
Message-ID: <11bcf9l$l7le$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> <11ba02r$3pl5h$1@dont-email.me> <11balon$1uor$2@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: fir <profesor.fir@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Thu, 22 Oct 2026 09:51:13 +0200
Organization: A noiseless patient Spider
Lines: 69
Message-ID: <11bcf9l$l7le$1@dont-email.me>
References: <119qf6l$2rmg3$1@dont-email.me> <11ba02r$3pl5h$1@dont-email.me>
 <11balon$1uor$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 22 Oct 2026 07:51:17 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="695982"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/LWwwJP25UolCBfi/x0C0SNh3MczqD9dY="; posting-host="0b30788676943a83f79a25d06a15ee98"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101
 Firefox/140.0 SeaMonkey/2.53.24
Cancel-Lock: sha1:ZkOH6wEuCW3T9noZmopnDIR8bqg= sha256:+dUQF4s8+kPiTMhVDVacmvmiLU407+/MJ4+uDoGxsIE=
	sha1:gGBju/E4xTVtBIRlX0MfBrGqJlY= sha256:7SncvQcPV/+NF1PuKy2qbUi2nFKFR/fGHQCf1HA9FjY=
In-Reply-To: <11balon$1uor$2@dont-email.me>