๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #426

Re: Taming The Switch-Statement

#426
From: bart
Date: Thu, 15 Oct 2026 17:10
39 lines
2987 bytes
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.

(My production lexers, even in my language so unoptimised, tend to be at 
least a magnitude faster and do more stuff such as symbol table lookups.)
Technical Details
Message-ID: <11ar1f5$2jod3$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> <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>

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: Thu, 15 Oct 2026 18:10:37 +0100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <11ar1f5$2jod3$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 15 Oct 2026 17:11:02 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2744739"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/FddBQDIm52oysYICGubah"; posting-host="3f7a5532ffaf673b54a2292b8a86a9eb"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:52I4jW7qVkeIvcX1C2dYMjj1oWA= sha256:EnmKe5I81U+gxR0TDpUy+GTW6VkpbANmwzE1XDvJaRc=
	sha1:x7HdnmWVpNX6m/xpNBQP87yi9Vg= sha256:VqvQr06E5qyTdZBeIIFkAiFxSXQsmlbvofb/8IDKuWY=
In-Reply-To: <11aqpl3$2gdup$1@dont-email.me>
Content-Language: en-GB