Path: csiph.com!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail From: cross@spitfire.i.gajendra.net (Dan Cross) Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Thu, 15 Oct 2026 20:42:53 -0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: <11ardsd$26m$1@reader2.panix.com> References: <119qf6l$2rmg3$1@dont-email.me> <11aqbqv$2avn3$1@dont-email.me> <11aqect$hpr$1@reader2.panix.com> <11aqpl3$2gdup$1@dont-email.me> Injection-Date: Thu, 15 Oct 2026 20:42:53 -0000 (UTC) Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80"; logging-data="2262"; mail-complaints-to="abuse@panix.com" X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: cross@spitfire.i.gajendra.net (Dan Cross) Xref: csiph.com comp.lang.c:403195 In article <11aqpl3$2gdup$1@dont-email.me>, bart wrote: >On 15/10/2026 12:45, Dan Cross wrote: >> In article <11aqbqv$2avn3$1@dont-email.me>, bart 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. Sure. >It's not even my opinion: it's fact. In your example, about a third of >'break' tokens are for taking care of switch. Ok. >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. Ok. >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.) > >There were some tricky bits of the C to translate, such as: > > break; > default: > break; > } > default: > *tp++ = ch; > break; > } > } > *tp++ = '\0'; > tt = TkSTRING; > >where it seems to break from one switch then sneakily falls through into >the default clauses of the enclosing one! Yup. >Well, here are some stats: > > C Mine > > Size 3374 2997 characters (both with hard tabs) > Non-blank lines 210 174 Lines Those seem like pretty meaningless statistics. I could really care less about 377 fewer bytes. Naturally, different languages will express these things differently. >I did try and run mine: > > c:\mapps>test > 1234 > tok: tt = tkident, token = '1234' > abc > tok: tt = tkident, token = 'abc' > >It shows both of these as an identifier. But yours does the same: > > c:\c>a > 1234 > tok: tt = 1003, token = '1234' > abc > tok: tt = 1003, token = 'abc' Yup. It's a poorly written program; I am not surprised there are bugs. It wasn't meant to be an illustration of exemplary programming, it was meant to illustrate a use case for a language construct that addresses a use case you appeared to want support for, but that are now upset about, because it was not provided in the way you like. Or something. >Whatever '1003' means, it's showing the same. So it will do (I don't >care if the code is buggy, just whether my version is reasonably faithful). This is actually a good example of the problem you often run into in these endless c.l.c threads: You seem to take a thing that was something that was only meant to show one thing, and asserting that it represents something other than what it was meant to show, and no matter how many times it is explained to you that it is not, in fact, what you seem to think that it is, you persist in your delusion and think that it proves something. But it doesn't, since you are starting from a false premise, at which point you whine that you are picked on, treated poorly, misunderstood, or generally dismissed, to which you conclude that this can only be due to a slavish devotion to C as it is, and a refusal to entertain that the language is not perfect. It is totally lost on you that people may be objecting to what you are saying on its own merits, since (ironically) you don't seem able to admit that your own ideas may have their own deficiencies. This whole discussion could be summarized as: Bart: "C sucks because Dennis Ritchie stupidly reused `break` for both loops and switch. He was a tasteless fool." All: "You can work around that really easily." Keith: "C added labeled break and continue...." Bart: "C sucks. My language is better. Here, I fixed C in 4 lines of code with my `breakloop`, but it still sucks because C is hopeless." Me: "No, the real problem is that there's no structured way break out of nested contexts; your thing only addresses one special case, and does not compose, so can't cover the general case." Bart: "No, it's the overloading. C is terrible and you're all just too blind to see it. You are all fools, like Dennis Ritchie." Me: "I mean, Keith told you how the language is being changed to address your problem _and_ the other problems in this general category." Bart: "Those other problems don't matter. C will never change. It will suck forever. I mean, have you ever even seen a use case for these labeled blocks? I don't like them, therefore they suck, just like C. They also suck because they solve a problem I don't care about. I have been doing this for 45 years." Me: "Here's a program that illustrates the problem. The code is shit, but shows how it can be used...." Bart: "This program sucks! You don't _need_ to do it this way." Me: "...I mean, I told you it sucked when I posted it...." Bart: "...I rewrote it in my language. I saved 377 bytes. See how much C sucks now? My language is better. Me: "...." Bart: "My lexer is 50% faster than your lexer. My production code is an order of magnitude faster. I am a very smart boy, and deserve a very special gold star on my report card." Me: "...Bruh." Bart: "Dennis Ritchie was a fool. A fool, I say! Haha! Ahahaha! Muwhahaha!" >Of course, my actual lexers have a different structure. If I actually wanted a real lexer for C, I'd probably use a lexer generator to generate one from a declarative description of the language's lexemes. Now then. Did you see how it used labeled break and continue to move about through the various control structures in ways that would not be representable if you only had `breakloop`? Yes, of course you can restructure the code, but that's not the point; the point was only to show how one might use labeled loops and switches and so on to implement control flows that one cannot express _without_ such facil The irony is that you are saying, in effect, "oh but you don't actually _need_ to do it that way..." to something you don't care for, when throughout the thread you have been specifically rejecting that same argument as a response your assertion that something that addressed this very use case was badly needed, to fix Dennis Ritchie's "mistake" of using `break` for both loops and `switch`. Seriously. The stunning lack of self-awareness is really quite breathtaking. - Dan C.