🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #940

Re: Taming The Switch-Statement

#940
From: fir
Date: Wed, 28 Oct 2026 13:06
40 lines
2683 bytes
chine.bleu pisze:
> bartc wrote:
>>> maybe try with like
>>>
>>> case x%2==0 //2 4 6 8 10 12
>>> case x%3==0 //3 6 9 12
>>
>> No, cases '6' and '12' are also true for x%2==0. Unless you want these
>> to be non-exclusive?
>>
>>> default  // 1 5 7 11 13
> 
> You can do guards with C syntax.
> 
> if (x%2==0) {...; goto out;}
> if (x%3==0) {...; goto out;}
> ...
> {default action....} out:;
> 

not really, guess why


besides the construcj are to write things cleaner and easier to read, 
more tidy..and if soe imo couple of construct should be present

for some cases

if none(a,b,c)  then {} else {} would be ok for other

if (){} or if() {} else {} is not bad

dictionary is also ok (i was writing in inviting dictionaries in c back 
then) or this goto (number) is also ok

if-else as it is today i find incomplete and switch as it is i find ugly
(though if some well realizes its in fact goto it may be seen better imo
(realizing its goto made it it have a bit more value in my etyes - but 
stil its badly done goto and its ugly
Technical Details
Message-ID: <11bsrvu$2ecic$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> <11bnfpm$i84l$1@dont-email.me> <11bng23$iblc$1@dont-email.me> <11bngj1$ifj5$1@dont-email.me> <11bnnbg$l7i1$1@dont-email.me> <11bntk0$nsbo$1@dont-email.me> <11bnvbq$olbj$1@dont-email.me> <11bnvl2$opb9$1@dont-email.me> <11bnvug$otdl$1@dont-email.me> <11bsreh$2dr1j$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: Wed, 28 Oct 2026 14:06:03 +0100
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <11bsrvu$2ecic$1@dont-email.me>
References: <119qf6l$2rmg3$1@dont-email.me> <11ba02r$3pl5h$1@dont-email.me>
 <11bnfpm$i84l$1@dont-email.me> <11bng23$iblc$1@dont-email.me>
 <11bngj1$ifj5$1@dont-email.me> <11bnnbg$l7i1$1@dont-email.me>
 <11bntk0$nsbo$1@dont-email.me> <11bnvbq$olbj$1@dont-email.me>
 <11bnvl2$opb9$1@dont-email.me> <11bnvug$otdl$1@dont-email.me>
 <11bsreh$2dr1j$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 28 Oct 2026 13:06:07 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2568780"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+MZ+Q5C4Qv7G9+i/VS3UrpZpiardloUE4="; posting-host="0c05802531f1a4b723135877d29c6d22"
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:/WrkYkelywvo7idl1vsCuOBSlG8= sha256:qjEFZ7gZj8h+1dRRcIW5x3ks78C1Jd6kqFvjn+gwq2Q=
	sha1:/7UoFQ6OK04k4h0Gk8JUFUes9zk= sha256:BveS4RZUyWLMecl/WrwOmJ9gdDeGRRmW72OTLg937NU=
In-Reply-To: <11bsreh$2dr1j$2@dont-email.me>