Article View: comp.lang.c
Article #438Re: Taming The Switch-Statement
From: bart
Date: Fri, 16 Oct 2026 01:42
Date: Fri, 16 Oct 2026 01:42
60 lines
3612 bytes
3612 bytes
On 15/10/2026 18:10, bart wrote: > On 15/10/2026 15:57, bart wrote: >> On 15/10/2026 12:45, Dan Cross wrote: >>> In article <11aqbqv$2avn3$1@dont-email.me>, bartย <bc@freeuk.com> wrote: >> >>>> Perhaps that reused keyword thing is a bigger deal than you think. The >>>> effect of it is unnecessary obfuscation. >>> >>> This is certainly not evidence of that.ย This is just your >>> assertion that you took a silly example and apparently (maybe?) >>> improved it, based on some unstated, but apparently subjective, >>> criteria. >> I am stating that 'break' used to fix C's poor 'switch' feature >> interferes with 'break' used for loops. >> >> It's not even my opinion: it's fact. In your example, about a third of >> 'break' tokens are for taking care of switch. >> >> My opinion is that it generates pointless clutter (this it would do >> even if a different keyword was used), and it can get confusing when >> switch and loop are mixed up. >> >> I actually took your program and ported it to my syntax, as I was >> curious how it would look. This is the result: >> >> https://github.com/bart-2026/langs/blob/main/lexertest.m >> >> (It's been spaced out more, vertically.) > >> Well, here are some stats: > >> I did try and run mine: > Enough worked that I decided to try a speed test. Both use exactly the > same algorithm, and I didn't expect either to be fast. > > Still, the version in my language/compiler was 50% faster than the C > compiled with gcc-O3. I don't know why. I'm mildly curious about this even if no one else is (or they think it is some sort of boasting although I said I didn't know the reason). I've now converted DC's C program to use normal gotos, so that I can try with other compilers. For my test (10M lines of the same 8 tokens): gcc 16.x 28 seconds (any opt. level) gcc 14.x 18 seconds clang-O3 18 seconds tcc 18 seconds bcc 18 seconds mm 18 seconds (my lang) Figures are pretty much at those two levels. So it's more likely a library thing and it is i/o bound. Anyway, I'm done with all this now; my C compiler and related apps are no more.
Technical Details
Message-ID:
<11arveu$2tq3v$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> <11aoqa9$1rgda$1@dont-email.me> <11apa4b$kv$1@reader2.panix.com> <11aqbqv$2avn3$1@dont-email.me> <11aqect$hpr$1@reader2.panix.com> <11aqpl3$2gdup$1@dont-email.me> <11ar1f5$2jod3$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: bart <bc@freeuk.com> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Fri, 16 Oct 2026 02:42:53 +0100 Organization: A noiseless patient Spider Lines: 60 Message-ID: <11arveu$2tq3v$1@dont-email.me> References: <119qf6l$2rmg3$1@dont-email.me> <11aoqa9$1rgda$1@dont-email.me> <11apa4b$kv$1@reader2.panix.com> <11aqbqv$2avn3$1@dont-email.me> <11aqect$hpr$1@reader2.panix.com> <11aqpl3$2gdup$1@dont-email.me> <11ar1f5$2jod3$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 16 Oct 2026 01:42:55 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3074175"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UADB+Pxj+xxfrheN6TNyM"; posting-host="9fff42d3173963a8ee0c00ef9e61f4e2" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:QtvEEiOshpsp1wsipR5si9YM7mU= sha256:8zPXJAtP7NFy3ff/kD/vQX53yYn+2CywhlShsNK2ByU= sha1:dnl+63VjiuAcBpg6CeJhkH78RLM= sha256:tZAnUXT7dTly+hFgxaxyajDrgdquFp69OwBk0RkJLBc= In-Reply-To: <11ar1f5$2jod3$1@dont-email.me> Content-Language: en-GB