Article View: comp.lang.c
Article #941Re: Taming The Switch-Statement
From: fir
Date: Wed, 28 Oct 2026 13:21
Date: Wed, 28 Oct 2026 13:21
69 lines
3622 bytes
3622 bytes
fir pisze:
> 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
>
there is also a topid if this () in : if() {}
are ereally needed imo those () are like specially not fitting
then keyword is ommited in c and sometimes it lack is sligthly seen imo
if then would be presen then the space among if and then would be clear
and that would not need (), even now if some uses brackets {} if would
be look better
if a <2 {}
it doesnt seem to clash with anything though i dons say here i know for
sure but just nota a topic thsose () specially dont fit
those logical values (or its tuples/vectors) are besides so separate
than normal expressions that even if is not needed
x>0 and x<w {}
x>0, x<w some {} none {} both {} //??
this last looks weirs but some logical reasaning showed such things
could be usefull - as you dont need to repeat those logical conditions
> 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:
<11bsss7$2en9g$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-mailReferences:
<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> <11bsrvu$2ecic$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: fir <profesor.fir@gmail.com> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Wed, 28 Oct 2026 14:21:08 +0100 Organization: A noiseless patient Spider Lines: 69 Message-ID: <11bsss7$2en9g$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> <11bsrvu$2ecic$1@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:21:12 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2579760"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18S+8MKKHWBgle+7YyPdUPzmVhIJCZogC8="; 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:9QspTnBkFWkJVjvVTWy4rfqEb7A= sha256:wUkyb86fae8ge+DyJZK6Z/AYNYft57iVNQcv/S7I9OU= sha1:3XfSAvxJIksbw8HfcMo6ukwjfYI= sha256:3fOct0EHhhVuvgJ6q/ld33tqzfV6SSvKW9cDjvzBIgg= In-Reply-To: <11bsrvu$2ecic$1@dont-email.me>