Article View: comp.lang.c
Article #950Re: Taming The Switch-Statement
From: Janis Papanagnou
Date: Wed, 28 Oct 2026 14:52
Date: Wed, 28 Oct 2026 14:52
26 lines
2147 bytes
2147 bytes
On 2026-10-28 13:56, chine.bleu wrote:
> 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.
Use of the word "guards" is misleading here, since Dijkstra's Guards
are not appropriately described by the deterministic code below.
Janis
>
> if (x%2==0) {...; goto out;}
> if (x%3==0) {...; goto out;}
> ...
> {default action....} out:;
>
Technical Details
Message-ID:
<11bt27e$139ta$6@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>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: Wed, 28 Oct 2026 15:52:30 +0100 Organization: A noiseless patient Spider Lines: 26 Message-ID: <11bt27e$139ta$6@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 14:52:31 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1157034"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/J0opA6CTL5WwK6zZ4paRi"; posting-host="880663668c89bd06f8f144317597f206" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:tmmh4DeSkKXX+OA2GnXP84YdlQE= sha256:pji4+N1du0DcAkyWDqwE2H4uh7SIZfHaNvR7bhEClmA= sha1:6GnwZz4Pl7DiN92eTlxHWajYXgY= sha256:xhqSjPIoq+Tu7A0gF1901og6sxA6eA/t9ZFjhLw74sw= Content-Language: en-US In-Reply-To: <11bsreh$2dr1j$2@dont-email.me>