Thread View: comp.lang.c
412 messages
412 total messages
Page 3 of 9
Started by Lawrence D’Oliveiro
Sat, 10 Oct 2026 00:25
Page 3 of 9 • 412 total messages
Re: Taming The Switch-Statement
Author: bart
Date: Mon, 12 Oct 2026 18:52
Date: Mon, 12 Oct 2026 18:52
24 lines
2505 bytes
2505 bytes
On 12/10/2026 19:46, Scott Lurndal wrote: > cross@spitfire.i.gajendra.net (Dan Cross) writes: >> In article <11aidi3$3gbu4$1@dont-email.me>, bart <bc@freeuk.com> wrote: >>> On 12/10/2026 06:22, David Brown wrote: >>>> On 12/10/2026 00:05, bart wrote: >>> > >> I kinda sorta agree that requiring `break` between `case` >> statements in C was an historical mistake, but here we are: it >> is 2026, and the language has done that for more than 50 years >> now. The ship for changing it has sailed. What is one left to >> do, besides acknowledging it as a wart on the face of the >> langauge? > > I, on the other hand, don't consider it a mistake, in the > context of the C and C++ languages. I've used the ability to > fall through in a significant fraction (50% in some applications) of > the switch statements that I've written over the last > five decades of C and C++programming. So 99% of programmers have to suffer needing to pointlessly write 'break' everywhere, rather than the 1% having to write 'fallthru'. Although it sounds like even you need fall-through less often than break.
Re: Taming The Switch-Statement
Author: Michael S
Date: Mon, 12 Oct 2026 19:02
Date: Mon, 12 Oct 2026 19:02
28 lines
2872 bytes
2872 bytes
On Sun, 11 Oct 2026 14:28:29 -0700 Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: > bart <bc@freeuk.com> writes: > [...] > > 'break' to quit a loop early is part of the language, so why > > shouldn't someone make use it? > > Agreed. (There are coding styles that require loops to exit only at > the bottom, but that's not what we're talking about.) > > > It just its use can be interfered with when 'switch' is involved. > > Yes. Everyone here knows that, and knew it before you started talking > about it. > > Michael S wrote above that "The cases where I want to break out of > the loop from the switch in the body of the loop are very common." > Tim Rentsch questioned the "very common" part of that, and asked > for an example. You jumped in and asserted that an example isn't > necessary, because you misunderstood what was being said. > I didn't read the whole subthread, but from what I read it seems that the only reader that misunderstood my statement was David Brown. The rest, including bart, understood just fine.
Re: Taming The Switch-Statement
Author: David Brown
Date: Mon, 12 Oct 2026 19:09
Date: Mon, 12 Oct 2026 19:09
33 lines
3177 bytes
3177 bytes
On 12/10/2026 21:02, Michael S wrote: > On Sun, 11 Oct 2026 14:28:29 -0700 > Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: > >> bart <bc@freeuk.com> writes: >> [...] >>> 'break' to quit a loop early is part of the language, so why >>> shouldn't someone make use it? >> >> Agreed. (There are coding styles that require loops to exit only at >> the bottom, but that's not what we're talking about.) >> >>> It just its use can be interfered with when 'switch' is involved. >> >> Yes. Everyone here knows that, and knew it before you started talking >> about it. >> >> Michael S wrote above that "The cases where I want to break out of >> the loop from the switch in the body of the loop are very common." >> Tim Rentsch questioned the "very common" part of that, and asked >> for an example. You jumped in and asserted that an example isn't >> necessary, because you misunderstood what was being said. >> > > I didn't read the whole subthread, but from what I read it seems that > the only reader that misunderstood my statement was David Brown. The > rest, including bart, understood just fine. > If I have misunderstood, I would love to be corrected. In a number of my posts I said I was not sure what you were talking about, and would need more explanation.
Re: Taming The Switch-Statement
Author: Michael S
Date: Mon, 12 Oct 2026 19:31
Date: Mon, 12 Oct 2026 19:31
67 lines
4140 bytes
4140 bytes
On Mon, 12 Oct 2026 21:09:25 +0200 David Brown <david.brown@hesbynett.no> wrote: > On 12/10/2026 21:02, Michael S wrote: > > On Sun, 11 Oct 2026 14:28:29 -0700 > > Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: > > > >> bart <bc@freeuk.com> writes: > >> [...] > >>> 'break' to quit a loop early is part of the language, so why > >>> shouldn't someone make use it? > >> > >> Agreed. (There are coding styles that require loops to exit only > >> at the bottom, but that's not what we're talking about.) > >> > >>> It just its use can be interfered with when 'switch' is involved. > >>> > >> > >> Yes. Everyone here knows that, and knew it before you started > >> talking about it. > >> > >> Michael S wrote above that "The cases where I want to break out of > >> the loop from the switch in the body of the loop are very common." > >> Tim Rentsch questioned the "very common" part of that, and asked > >> for an example. You jumped in and asserted that an example isn't > >> necessary, because you misunderstood what was being said. > >> > > > > I didn't read the whole subthread, but from what I read it seems > > that the only reader that misunderstood my statement was David > > Brown. The rest, including bart, understood just fine. > > > > If I have misunderstood, I would love to be corrected. In a number > of my posts I said I was not sure what you were talking about, and > would need more explanation. > I thought that my comment is hard to misunderstand, but you proved me wrong. So I'd try to elaborate: switch() nested within loop is very common in my practice and I suppose in practice of everybody else. In my practice, but obviously not in practice of Tim Rentsch, it is sufficiently common to want to transfer control from point within such nested switch to point immediately following the containing loop. If break out of loop and break out of switch were different keyword, it would be very easy to do. But since the keyword is shared I have to use workarounds. Many of them were mentioned in the sub-thread. All workarounds work. They are all less simple and less elegant than what would have been possible if break keyword was not shared.
Re: Taming The Switch-Statement
Author: bart
Date: Mon, 12 Oct 2026 19:38
Date: Mon, 12 Oct 2026 19:38
107 lines
5488 bytes
5488 bytes
On 12/10/2026 18:58, Dan Cross wrote:
> In article <11ainqf$3kkvd$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>> This is valid C still, but it doesn't have the same behaviour.
>
> Yes. I guess I fail to see the point of these, as what you are
> trying to show seems obvious to me, and I strongly suspect it is
> obvious to others, as well.
>
> Are you suggesting that people are unaware of how `break`
> interacts with `switch` inside of a loop? I don't think that is
> true; I think people are well aware, but know how to work around
> it and don't see it as a huge impediment; more of a mild
> inconvenience.
>
> Or are you suggesting that they are trying to defend the design
> of the language in this regard?
That's what it seems like: obstinately trying to pretend it is not a
flaw, that it makes perfect sense, then you never want to do any of the
stuff where it causes problems anyway etc.
There are several issues discussed regarding switch:
* That its structure is totally chaotic (there /is/ no structure)
* That 'break' is needed to escape from the middle of that statement to
the end
* That that 'break' happens also to clash, needlessly, with loop-break
* And also with 'case' only doing one label at a time, instead of
being able to do, for example: 'case a, b, c:' or 'case x...y',
although some of this is taken care of via extensions.
There's quite a lot that could have been done much better!
> I similarly don't think that is
> true; I have certainly been annoyed by this, and I suspect
> others have as well. But again, people know how to work around
> it.
Yes, various workarounds are needed, such as the gotos in your examples.
But if we're going to use 'goto', then why bother with 'break' at all?
Presumably it is to make life easier.
> C is not anyone's mother; I doubt anyone who is not a kook feels
> like they need to rise to the defense of its honor when it is
> criticized.
Defending every shortcoming or quirk to the death seems common here. And
there will always be people to whom they are an invaluable feature (see
SL's recent post).
> What I think some people are sort of mystified by is this idea
> that this one thing is such a deal-breaker as to render the
> language unuseable.
In my case I would find it unusable for major projects if I had to code
manually. I'm just to spoilt for one, but always I'm a terrible typist
and C needs a LOT of fiddly typing.
>> Maybe, some compilers with certain options may point out something about
>> fall-through, so you're aware something's amiss, but it doesn't get
>> around the problem: you can't simply swap if-else chains with switch
>> even when the latter is a better fit.
>>
>> This is a definite flaw in the language.
>
> It _can be_ an _annoyance_ in the language, sure. Is it a,
> "definite flaw"? That is subjective. You clearly feel that it
> is. I couldn't say whether anyone else feels that way; I think
> it's too minor to matter for most programmers.
It's minor until it bites - see the example below.
>> [snip]
>> In my language and in my programs, breaking out of a loop from within a
>> multi-way case/switch selection is a very, very common idiom which is
>> denied to C users.
>
> And yet, C is used successfully by millions of programmers
> around the world, the results of which are used by billions of
> users daily.
This is my first example expressed in C (note those first three args are
passed by reference):
while (pmtype = nextcmdparam(¶mno, &name, &value, "m") {
switch (pmtype)
case pm_option: ...; break;
case pm_sourcefile:
if (passlevel == run_pass || passlevel == runpcl_pass) {
break;
Except I can't use break like that. So I have to find a workaround.
This is also 30% more tokens than my original, and that's before I fix
this problem.
So I'm sure C is perfectly usable, what we can't quantity easily is how
much extra effort is needed to get things done compared to a more
amenable syntax.
Re: Taming The Switch-Statement
Author: Scott Lurndal
Date: Mon, 12 Oct 2026 19:42
Date: Mon, 12 Oct 2026 19:42
28 lines
2247 bytes
2247 bytes
bart <bc@freeuk.com> writes: >On 12/10/2026 19:46, Scott Lurndal wrote: >> cross@spitfire.i.gajendra.net (Dan Cross) writes: >>> In article <11aidi3$3gbu4$1@dont-email.me>, bart <bc@freeuk.com> wrote: >>>> On 12/10/2026 06:22, David Brown wrote: >>>>> On 12/10/2026 00:05, bart wrote: >>>> >> >>> I kinda sorta agree that requiring `break` between `case` >>> statements in C was an historical mistake, but here we are: it >>> is 2026, and the language has done that for more than 50 years >>> now. The ship for changing it has sailed. What is one left to >>> do, besides acknowledging it as a wart on the face of the >>> langauge? >> >> I, on the other hand, don't consider it a mistake, in the >> context of the C and C++ languages. I've used the ability to >> fall through in a significant fraction (50% in some applications) of >> the switch statements that I've written over the last >> five decades of C and C++programming. > >So 99% of programmers have to suffer Please, speak for yourself. You have no clue what programmers[*] think, or whether they suffer from the requirement to use 'break' to avoid falling through to the next case. [*] You, being atypical, are particularly ill-suited to speak for others.
Re: Taming The Switch-Statement
Author: Scott Lurndal
Date: Mon, 12 Oct 2026 19:52
Date: Mon, 12 Oct 2026 19:52
22 lines
1770 bytes
1770 bytes
bart <bc@freeuk.com> writes:
>On 12/10/2026 18:58, Dan Cross wrote:
>> In article <11ainqf$3kkvd$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>
>This is my first example expressed in C (note those first three args are
>passed by reference):
>
> while (pmtype = nextcmdparam(¶mno, &name, &value, "m") {
> switch (pmtype)
> case pm_option: ...; break;
> case pm_sourcefile:
> if (passlevel == run_pass || passlevel == runpcl_pass) {
> break;
Aside from the incorrect syntax, it's really difficult to
determine your intent from this code fragment.
It's likely that folks here could provide more idiomatic
C if you described the problem you're attempting to solve
rather than providing an incomplete and incorrect code
fragment.
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Mon, 12 Oct 2026 20:32
Date: Mon, 12 Oct 2026 20:32
62 lines
5185 bytes
5185 bytes
On 2026-10-12 21:31, Michael S wrote:
> On Mon, 12 Oct 2026 21:09:25 +0200
> David Brown <david.brown@hesbynett.no> wrote:
>>> [...]
>>
>> If I have misunderstood, I would love to be corrected. In a number
>> of my posts I said I was not sure what you were talking about, and
>> would need more explanation.
>
> I thought that my comment is hard to misunderstand, but you proved
> me wrong. So I'd try to elaborate:
>
> switch() nested within loop is very common in my practice and I suppose
> in practice of everybody else.
Something on a level like that was that I recall you had originally
written. So this doesn't explain more than your original statement
about that. It is quite clear (and I'm positive that it's as clear
to David). As far as I'm concerned, and that was how I understood
David's question, I'd (also) be (but only mildly!) interested what
the *concrete* _application cases_ those actually are since they (as
you said) appear so dominantly in your C-programs. Not the technical
structure ("for() switch() break;") but which types of applications
or application-semantical code patterns would require those that it
appears so often in your context. - My own interest here is limited,
as said, since it certainly doesn't apply to my C-code, and I never
noticed that it would be predominantly a prominent pattern in others'
C-code, beyond being one specific C-patterns amongst hundreds other
common C-patterns. - If it were extraordinarily common in your case
I'd indeed have thought about employing some standard pattern as a
substitute (see one of I think Dan's recent posts), and as you also
confirmed in this post - I snipped it - to actually have done this.
I hope that clarifies what some readers felt was missing.
Myself I also think that both, switch()-loop() and loop()-switch(),
constructs are just _corner-cases_ where doubling the 'break' could
help people, but it wouldn't at all address the more general tasks,
where e.g. more than just one loop and switch is nested.[*] - Myself
I'd certainly expect a solution that is more generally applicable;
labelled control-constructs are one way, even numbered breaks would
be an IMO acceptable extension. - But "C" only supports a one-level
local 'break' and a non-local flexible/arbitrary 'goto'. Two distinct
breaks would just pollute the name-space and not address the inherent
and basic restriction of being still just one-level breaks. - And I'm
confident that even then there'd pop up some pathological person and
complain about these breaks addressing not more that one levels.
Janis
[*] Note the many conditions we have here; exactly two specific and
different constructs, exactly two and not one or more than two, and
the case that you want to leave not one but both. - Can you imagine
that folks are wondering about what application context that stems
from that it appears so often (in your domain). - I think that was
the question that David had. It was certainly the question that
manifested in my mind when I read your post; only that I'm not too
much interested about it if you're operating in a domain where that
is more common than usual (and also don't bother to answer that).
> [...]
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Mon, 12 Oct 2026 20:56
Date: Mon, 12 Oct 2026 20:56
48 lines
3290 bytes
3290 bytes
On 2026-10-12 21:52, Scott Lurndal wrote:
> bart <bc@freeuk.com> writes:
>> On 12/10/2026 18:58, Dan Cross wrote:
>>> In article <11ainqf$3kkvd$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>>
>
>> This is my first example expressed in C (note those first three args are
>> passed by reference):
>>
>> while (pmtype = nextcmdparam(¶mno, &name, &value, "m") {
>> switch (pmtype)
>> case pm_option: ...; break;
>> case pm_sourcefile:
>> if (passlevel == run_pass || passlevel == runpcl_pass) {
>> break;
>
> Aside from the incorrect syntax, it's really difficult to
> determine your intent from this code fragment.
Well, to me it's clear what he meant by this code.
But it's unimportant since it doesn't add anything to what he has
repeated countless times; that in a loop()-switch() structure the
inner 'break' in the 'switch' would not leave the loop().
Such code exists in various forms, it's not something "strange".
It's also no problem that couldn't be addressed by other patterns.
(But he refuses to use them, or he's just blind to not see them.)
A loop()-specific 'break' would serve him (if he wants to abstain
from 'goto', or is refusing from doing just a slight code change).
(Maybe if he'd just hold his breath long enough something would
happen?)
>
> It's likely that folks here could provide more idiomatic
> C if you described the problem you're attempting to solve
> rather than providing an incomplete and incorrect code
> fragment.
I think it's sufficiently idiomatic. And I don't think that he could
provide anything where the answers would pass though the mental block
he obviously has. The thread was (by content) dead already very soon.
IMO it makes no sense to continue arguing with him.
Janis
Re: Taming The Switch-Statement
Author: bart
Date: Mon, 12 Oct 2026 20:57
Date: Mon, 12 Oct 2026 20:57
34 lines
2695 bytes
2695 bytes
On 12/10/2026 20:52, Scott Lurndal wrote:
> bart <bc@freeuk.com> writes:
>> On 12/10/2026 18:58, Dan Cross wrote:
>>> In article <11ainqf$3kkvd$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>>
>
>> This is my first example expressed in C (note those first three args are
>> passed by reference):
>>
>> while (pmtype = nextcmdparam(¶mno, &name, &value, "m") {
>> switch (pmtype)
>> case pm_option: ...; break;
>> case pm_sourcefile:
>> if (passlevel == run_pass || passlevel == runpcl_pass) {
>> break;
>
> Aside from the incorrect syntax, it's really difficult to
> determine your intent from this code fragment.
Really? It's attempting to break out of the while-loop from inside that
switch statement. What we've been discussing at length.
But it won't work like this because in this context, that 'break' is
switch-break not loop-break.
> It's likely that folks here could provide more idiomatic
> C if you described the problem you're attempting to solve
> rather than providing an incomplete and incorrect code
> fragment.
I'd be interested in the idiomatic C that doesn't involve rewriting my
code or adding complexity in order to get around that silly clash.
Re: Taming The Switch-Statement
Author: bart
Date: Mon, 12 Oct 2026 21:05
Date: Mon, 12 Oct 2026 21:05
64 lines
5427 bytes
5427 bytes
On 12/10/2026 21:32, Janis Papanagnou wrote:
> On 2026-10-12 21:31, Michael S wrote:
>> On Mon, 12 Oct 2026 21:09:25 +0200
>> David Brown <david.brown@hesbynett.no> wrote:
>>>> [...]
>>>
>>> If I have misunderstood, I would love to be corrected. In a number
>>> of my posts I said I was not sure what you were talking about, and
>>> would need more explanation.
>>
>> I thought that my comment is hard to misunderstand, but you proved
>> me wrong. So I'd try to elaborate:
>>
>> switch() nested within loop is very common in my practice and I suppose
>> in practice of everybody else.
>
> Something on a level like that was that I recall you had originally
> written. So this doesn't explain more than your original statement
> about that. It is quite clear (and I'm positive that it's as clear
> to David). As far as I'm concerned, and that was how I understood
> David's question, I'd (also) be (but only mildly!) interested what
> the *concrete* _application cases_ those actually are since they (as
> you said) appear so dominantly in your C-programs. Not the technical
> structure ("for() switch() break;") but which types of applications
> or application-semantical code patterns would require those that it
> appears so often in your context. - My own interest here is limited,
> as said, since it certainly doesn't apply to my C-code, and I never
> noticed that it would be predominantly a prominent pattern in others'
> C-code, beyond being one specific C-patterns amongst hundreds other
> common C-patterns. - If it were extraordinarily common in your case
> I'd indeed have thought about employing some standard pattern as a
> substitute (see one of I think Dan's recent posts), and as you also
> confirmed in this post - I snipped it - to actually have done this.
>
> I hope that clarifies what some readers felt was missing.
>
> Myself I also think that both, switch()-loop() and loop()-switch(),
> constructs are just _corner-cases_ where doubling the 'break' could
> help people, but it wouldn't at all address the more general tasks,
> where e.g. more than just one loop and switch is nested.[*] - Myself
> I'd certainly expect a solution that is more generally applicable;
> labelled control-constructs are one way, even numbered breaks would
> be an IMO acceptable extension. - But "C" only supports a one-level
> local 'break' and a non-local flexible/arbitrary 'goto'. Two distinct
> breaks would just pollute the name-space and not address the inherent
> and basic restriction of being still just one-level breaks. - And I'm
> confident that even then there'd pop up some pathological person and
> complain about these breaks addressing not more that one levels.
>
> Janis
>
> [*] Note the many conditions we have here; exactly two specific and
> different constructs, exactly two and not one or more than two, and
> the case that you want to leave not one but both. - Can you imagine
> that folks are wondering about what application context that stems
> from that it appears so often (in your domain). - I think that was
> the question that David had. It was certainly the question that
> manifested in my mind when I read your post; only that I'm not too
> much interested about it if you're operating in a domain where that
> is more common than usual (and also don't bother to answer that).
Such a lot of words to say little, if anything, that is comprehensible.
Oh, it must be my 'mental block'!
Re: Taming The Switch-Statement
Author: David Brown
Date: Mon, 12 Oct 2026 21:14
Date: Mon, 12 Oct 2026 21:14
92 lines
5877 bytes
5877 bytes
On 12/10/2026 21:31, Michael S wrote: > On Mon, 12 Oct 2026 21:09:25 +0200 > David Brown <david.brown@hesbynett.no> wrote: > >> On 12/10/2026 21:02, Michael S wrote: >>> On Sun, 11 Oct 2026 14:28:29 -0700 >>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >>> >>>> bart <bc@freeuk.com> writes: >>>> [...] >>>>> 'break' to quit a loop early is part of the language, so why >>>>> shouldn't someone make use it? >>>> >>>> Agreed. (There are coding styles that require loops to exit only >>>> at the bottom, but that's not what we're talking about.) >>>> >>>>> It just its use can be interfered with when 'switch' is involved. >>>>> >>>> >>>> Yes. Everyone here knows that, and knew it before you started >>>> talking about it. >>>> >>>> Michael S wrote above that "The cases where I want to break out of >>>> the loop from the switch in the body of the loop are very common." >>>> Tim Rentsch questioned the "very common" part of that, and asked >>>> for an example. You jumped in and asserted that an example isn't >>>> necessary, because you misunderstood what was being said. >>>> >>> >>> I didn't read the whole subthread, but from what I read it seems >>> that the only reader that misunderstood my statement was David >>> Brown. The rest, including bart, understood just fine. >>> >> >> If I have misunderstood, I would love to be corrected. In a number >> of my posts I said I was not sure what you were talking about, and >> would need more explanation. >> > > I thought that my comment is hard to misunderstand, but you proved > me wrong. So I'd try to elaborate: > > switch() nested within loop is very common in my practice and I suppose > in practice of everybody else. Okay. I am not sure it is that common, and it is not a combination I make much use of in my own code. Many people aim to keep their functions short, while switches can lead to long functions - I think it is quite common in such circumstances to put the switch inside a function of its own, called from within the loop. > > In my practice, but obviously not in practice of Tim Rentsch, it > is sufficiently common to want to transfer control from point within > such nested switch to point immediately following the containing loop. > I cannot remember ever having need of doing something like that - at least not so that I thought "it would be nice if there were a way to break out of the loop from here". Maybe that is an effect of the way I tend to structure my code, or split up my functions - but I do not split my functions to achieve this effect. And the other common resolution, using a goto, is also not something I have needed. Different people have different styles, and occasionally you come across a code structure that someone else thinks is common, while you have never needed it yourself. > If break out of loop and break out of switch were different keyword, it > would be very easy to do. Now that I know what you are talking about, I can see how that would have helped. However, to me, that would seem a very niche usage and not something to consider for an additional keyword in the language. Labelled breaks that can also handle nested loops would, I think, be of significantly wider use while also handling your situation. > > But since the keyword is shared I have to use workarounds. Many of them > were mentioned in the sub-thread. All workarounds work. They are all > less simple and less elegant than what would have been possible if break > keyword was not shared. > Only you know your own code, and what you judge as elegant, so there's no argument here. Perhaps I have written code that you would think could have been written more clearly with a switch within a loop if C had two different "break" statements - but it is not a feature that I could see myself making use of.
Re: Taming The Switch-Statement
Author: Scott Lurndal
Date: Mon, 12 Oct 2026 21:21
Date: Mon, 12 Oct 2026 21:21
107 lines
4387 bytes
4387 bytes
bart <bc@freeuk.com> writes:
>On 12/10/2026 20:52, Scott Lurndal wrote:
>> bart <bc@freeuk.com> writes:
>>> On 12/10/2026 18:58, Dan Cross wrote:
>>>> In article <11ainqf$3kkvd$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>>>
>>
>>> This is my first example expressed in C (note those first three args are
>>> passed by reference):
>>>
>>> while (pmtype = nextcmdparam(¶mno, &name, &value, "m") {
>>> switch (pmtype)
>>> case pm_option: ...; break;
>>> case pm_sourcefile:
>>> if (passlevel == run_pass || passlevel == runpcl_pass) {
>>> break;
>>
>> Aside from the incorrect syntax, it's really difficult to
>> determine your intent from this code fragment.
>
>Really? It's attempting to break out of the while-loop from inside that
>switch statement. What we've been discussing at length.
It's not clear from the context within the code fragment that
you intended the second break to terminate the while loop,
or for the first break to terminate the while loop (or
for neither to continue the switch).
>
>But it won't work like this because in this context, that 'break' is
>switch-break not loop-break.
Which break? There are two.
>
>
>> It's likely that folks here could provide more idiomatic
>> C if you described the problem you're attempting to solve
>> rather than providing an incomplete and incorrect code
>> fragment.
>
>I'd be interested in the idiomatic C that doesn't involve rewriting my
>code or adding complexity in order to get around that silly clash.
>
Describe the problem the code is intended to
address. Rather than a very small fragment
of code without any context. It appears to be parsing
a command line, something done quite frequently in C.
e.g.
/*
* Process the input parameters.
*/
while ((c = getopt(argc, argv, "al:t:L:e:vV")) != EOF) {
switch (c) {
case 'a':
level = c_mp::REV_A; // Select revision A behavior
break;
case 'l':
logfile = optarg;
break;
case 't':
tracefile = optarg;
break;
case 'L':
libpath = optarg;
break;
case 'e':
startupfile = optarg;
break;
case 'v':
verbose = true;
break;
case 'V':
lp->log("%s\n", vsim_built);
exit(EXIT_SUCCESS);
}
}
The remaining arguments in argv[] are are application dependent,
and don't need to be handled in the body of the switch or the
while loop. They can easily be handled in a subsequent loop
over the remaining arguments.
In any case, using goto to leave a switch statement nested
in a loop is certainly an idiomatic construct that is widely
used to leave the outer loop early. Another option is to declare
a local bool before the switch in the while loop, initialized to false.
Set it to true when you want to bail early:
while (condition)
bool bail = false;
switch (blah) {
case 1:
break;
case 2:
if (fred == name) bail = true;
break;
}
if (bail) break;
do_something();
}
Whether that is beautiful or ugly is a matter of opinion,
and you've made yours very clear.
Re: Taming The Switch-Statement
Author: Michael S
Date: Mon, 12 Oct 2026 21:25
Date: Mon, 12 Oct 2026 21:25
69 lines
3788 bytes
3788 bytes
On Mon, 12 Oct 2026 21:57:46 +0100
bart <bc@freeuk.com> wrote:
> On 12/10/2026 20:52, Scott Lurndal wrote:
> > bart <bc@freeuk.com> writes:
> >> On 12/10/2026 18:58, Dan Cross wrote:
> >>> In article <11ainqf$3kkvd$1@dont-email.me>, bart <bc@freeuk.com>
> >>> wrote:
> >>
> >
> >> This is my first example expressed in C (note those first three
> >> args are passed by reference):
> >>
> >> while (pmtype = nextcmdparam(¶mno, &name, &value, "m") {
> >> switch (pmtype)
> >> case pm_option: ...; break;
> >> case pm_sourcefile:
> >> if (passlevel == run_pass || passlevel ==
> >> runpcl_pass) { break;
> >
> > Aside from the incorrect syntax, it's really difficult to
> > determine your intent from this code fragment.
>
> Really? It's attempting to break out of the while-loop from inside
> that switch statement. What we've been discussing at length.
>
Thank you. You correctly identified the most common of the patterns
that triggered my response to Janis that started this particular
sub-thread.
The important part missing in your excerpt is that there are several
variables declared and initialized before loop and further processed
both within and after the loop.
> But it won't work like this because in this context, that 'break' is
> switch-break not loop-break.
>
>
> > It's likely that folks here could provide more idiomatic
> > C if you described the problem you're attempting to solve
> > rather than providing an incomplete and incorrect code
> > fragment.
>
> I'd be interested in the idiomatic C that doesn't involve rewriting
> my code or adding complexity in order to get around that silly clash.
>
As far as I am concerned, my most common workaround is goto. Others can
have other preferences.
It works well, but the need to invent the name of the label is a bit
annoying.
BTW, Ada/VHDL solution, with optional label before the loop also
suffers from this particular defect. Yes, it is more "structural" than
goto. It is considered important by many people, supposedly including
yourself. But on my personal ladder of preferences "structureness" by
itself is not particularly high as long as it does not bring another
benefits, like, for example, locality=reduced scope.
Re: Taming The Switch-Statement
Author: bart
Date: Mon, 12 Oct 2026 21:46
Date: Mon, 12 Oct 2026 21:46
106 lines
5171 bytes
5171 bytes
On 12/10/2026 22:21, Scott Lurndal wrote:
> bart <bc@freeuk.com> writes:
>> On 12/10/2026 20:52, Scott Lurndal wrote:
>>> bart <bc@freeuk.com> writes:
>>>> On 12/10/2026 18:58, Dan Cross wrote:
>>>>> In article <11ainqf$3kkvd$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>>>>
>>>
>>>> This is my first example expressed in C (note those first three args are
>>>> passed by reference):
>>>>
>>>> while (pmtype = nextcmdparam(¶mno, &name, &value, "m") {
>>>> switch (pmtype)
>>>> case pm_option: ...; break;
>>>> case pm_sourcefile:
>>>> if (passlevel == run_pass || passlevel == runpcl_pass) {
>>>> break;
>>>
>>> Aside from the incorrect syntax, it's really difficult to
>>> determine your intent from this code fragment.
>>
>> Really? It's attempting to break out of the while-loop from inside that
>> switch statement. What we've been discussing at length.
>
> It's not clear from the context within the code fragment that
> you intended the second break to terminate the while loop,
> or for the first break to terminate the while loop (or
> for neither to continue the switch).
>
>>
>> But it won't work like this because in this context, that 'break' is
>> switch-break not loop-break.
>
> Which break? There are two.
Oh, OK. The original didn't need switch-break, it only had loop-break.
I added switch-break for the C version; that is the first 'break' above.
But loop-break is also 'break'. So it is still wreaking confusion!
For the same reason too: the intent in each case is different.
>
>>
>>
>>> It's likely that folks here could provide more idiomatic
>>> C if you described the problem you're attempting to solve
>>> rather than providing an incomplete and incorrect code
>>> fragment.
>>
>> I'd be interested in the idiomatic C that doesn't involve rewriting my
>> code or adding complexity in order to get around that silly clash.
>>
>
> Describe the problem the code is intended to
> address. Rather than a very small fragment
> of code without any context. It appears to be parsing
> a command line, something done quite frequently in C.
(Yes. It is normally parsing '[options] file [options]', but when a
filename is seen and that file is to be run immediately, it needs to
stop parsing as those trailing options will be processed by the
application that is run.
Maybe I should have used the simpler example.)
> In any case, using goto to leave a switch statement nested
> in a loop is certainly an idiomatic construct that is widely
> used to leave the outer loop early. Another option is to declare
> a local bool before the switch in the while loop, initialized to false.
>
> Set it to true when you want to bail early:
>
> while (condition)
> bool bail = false;
> switch (blah) {
> case 1:
> break;
> case 2:
> if (fred == name) bail = true;
> break;
> }
> if (bail) break;
> do_something();
> }
>
> Whether that is beautiful or ugly is a matter of opinion,
> and you've made yours very clear.
Using my proposal, that would look like:
while (condition)
newswitch (blah) {
case 1: # this is an empty block
case 2: # this is separate
if (fred == name) break;
}
do_something();
}
No 'break' is routinely needed for the switch. 'break' here exits the loop.
Not that this was serious, but probably 'case' would need a new keyword
since the meaning of 'case 1: case 2:' is significantly different
between old and new switch contexts.
Re: Taming The Switch-Statement
Author: Dan Cross
Date: Mon, 12 Oct 2026 22:20
Date: Mon, 12 Oct 2026 22:20
194 lines
8933 bytes
8933 bytes
In article <11ajcv8$3u33s$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>On 12/10/2026 18:58, Dan Cross wrote:
>> In article <11ainqf$3kkvd$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>
>>> This is valid C still, but it doesn't have the same behaviour.
>>
>> Yes. I guess I fail to see the point of these, as what you are
>> trying to show seems obvious to me, and I strongly suspect it is
>> obvious to others, as well.
>>
>> Are you suggesting that people are unaware of how `break`
>> interacts with `switch` inside of a loop? I don't think that is
>> true; I think people are well aware, but know how to work around
>> it and don't see it as a huge impediment; more of a mild
>> inconvenience.
>>
>> Or are you suggesting that they are trying to defend the design
>> of the language in this regard?
>
>That's what it seems like: obstinately trying to pretend it is not a
>flaw, that it makes perfect sense, then you never want to do any of the
>stuff where it causes problems anyway etc.
I think that may be your interpretation of what others are
saying, but that is not necessarily what they _are_ saying.
>There are several issues discussed regarding switch:
>
>* That its structure is totally chaotic (there /is/ no structure)
I think Keith said exactly that; it mixes structure and no
structure.
>* That 'break' is needed to escape from the middle of that statement to
> the end
I think the discussion is mostly you saying that this is
terrible, and others shrugging with their workarounds.
>* That that 'break' happens also to clash, needlessly, with loop-break
Yeah, I also think that's annoying.
>* And also with 'case' only doing one label at a time, instead of
> being able to do, for example: 'case a, b, c:' or 'case x...y',
> although some of this is taken care of via extensions.
That's also kind of irritating.
>There's quite a lot that could have been done much better!
I mean, yes. But as I said before, C is the language that it
is; I will acknowledge that it could have been better, but here
we are. Aside from that acknowledgement, what more is there to
actually do about it at this point?
>> I similarly don't think that is
>> true; I have certainly been annoyed by this, and I suspect
>> others have as well. But again, people know how to work around
>> it.
>
>Yes, various workarounds are needed, such as the gotos in your examples.
>But if we're going to use 'goto', then why bother with 'break' at all?
>
>Presumably it is to make life easier.
I don't know. I wasn't in the room when it was invented; its
immediate predecessor, BCPL, had no way to mark the end of a
`case` in a `switchon` at all (BCPL grew `ENDCASE` later),
though did have `valof` and `resultis` for obtaining the values
of _blocks_. So, one could write something like:
let howmany = valof switchon n into
$( case 0: resultis "zero"
case 1: resultis "one"
case 2: resultis "two"
default resultis "many"
$)
And so on; something one cannot do in C (but can in Rust).
Why did C bother with `break;` to end a `case` and not something
unique, like `ENDCASE` in later versions of BCPL?
I'm speculating, but I suspect it was because they wanted to
minimize the _need_ for `goto`; that unlike in BCPL blocks could
not return values; that `break` already existed to break out of a
loop and the control flow is not dissimilar conceptually; and
perhaps more importantly they were building a compiler intended
to run on a very, very small machine, shared by others, and ran
out of space to build something more elaborate. By the time
they had a bigger computer that could compile a better language,
the construct and its consequences were well understood and
there was a body of code that would have to change, and they did
not feel it was worth it.
At least, I imagine it was something like that.
>> C is not anyone's mother; I doubt anyone who is not a kook feels
>> like they need to rise to the defense of its honor when it is
>> criticized.
>
>Defending every shortcoming or quirk to the death seems common here. And
>there will always be people to whom they are an invaluable feature (see
>SL's recent post).
I don't think that anyone is doing that. I suspect it is the
opposite: others wonder why you latch onto every quirk or
shortcoming as evidence for your ultimately subjective opinion
that C is a bad language.
It is clear that you do not like C; you are not exactly hiding
it. But there is no C language politburo; no one will denounce
you for dreaming different dreams about the poor structure of
`switch`, and no one is going to challenge you to a duel over
your criticism of C.
But it is also clear that much of your dislike is opinion, based
on things that most others here just don't care about; the
pecularities of the `switch` statement are a good example. I
occasionally find it irritating, but 99% of the time I just
don't care; one learns to write `break` and one moves on with
one's life. Life is too short as it is to get worked up over
the `break` statement.
Others also point out that your criticism is often rooted in
misconceptions or misunderstandings of the language, and that is
fair: if you say something that is technically wrong about C as
evidence in support of your opinion about it, then you _should_
expect pushback. That's not anyone picking on you, it's them
holding you to a standard.
>> What I think some people are sort of mystified by is this idea
>> that this one thing is such a deal-breaker as to render the
>> language unuseable.
>
>In my case I would find it unusable for major projects if I had to code
>manually. I'm just to spoilt for one, but always I'm a terrible typist
>and C needs a LOT of fiddly typing.
Ok.
>>> Maybe, some compilers with certain options may point out something about
>>> fall-through, so you're aware something's amiss, but it doesn't get
>>> around the problem: you can't simply swap if-else chains with switch
>>> even when the latter is a better fit.
>>>
>>> This is a definite flaw in the language.
>>
>> It _can be_ an _annoyance_ in the language, sure. Is it a,
>> "definite flaw"? That is subjective. You clearly feel that it
>> is. I couldn't say whether anyone else feels that way; I think
>> it's too minor to matter for most programmers.
>
>It's minor until it bites - see the example below.
>
>[snip]
>This is my first example expressed in C (note those first three args are
>passed by reference):
>
> while (pmtype = nextcmdparam(¶mno, &name, &value, "m") {
> switch (pmtype)
> case pm_option: ...; break;
> case pm_sourcefile:
> if (passlevel == run_pass || passlevel == runpcl_pass) {
> break;
>
>Except I can't use break like that. So I have to find a workaround.
>
>This is also 30% more tokens than my original, and that's before I fix
>this problem.
The obvious syntax error aside, I'll wager that, to most C
programmers, this is still minor. I won't belabor the
workarounds as those are both well-known and have already been
discussed several times in this thread, alone. The only part
that bears mentioning here is that 99% of C programmers know
perfectly well how to deal with this and, frankly, just don't
find it that much of an imposition.
I think the impedence mismatch with what you're saying is that,
because it is so minor to so many people, it seems mystifying
that you think it's such a big deal.
>So I'm sure C is perfectly usable, what we can't quantity easily is how
>much extra effort is needed to get things done compared to a more
>amenable syntax.
That may be true. But I suspect that if you took a survey of,
say, 1000 C programmers, this would be unlikely to enter the top
10 complaints of more than a handful of them.
- Dan C.
Re: Taming The Switch-Statement
Author: Dan Cross
Date: Mon, 12 Oct 2026 22:35
Date: Mon, 12 Oct 2026 22:35
46 lines
2836 bytes
2836 bytes
In article <5W9zS.161421$98z8.84067@fx33.iad>, Scott Lurndal <slp53@pacbell.net> wrote: >cross@spitfire.i.gajendra.net (Dan Cross) writes: >>In article <11aidi3$3gbu4$1@dont-email.me>, bart <bc@freeuk.com> wrote: >>>On 12/10/2026 06:22, David Brown wrote: >>>> On 12/10/2026 00:05, bart wrote: >>> > >>I kinda sorta agree that requiring `break` between `case` >>statements in C was an historical mistake, but here we are: it >>is 2026, and the language has done that for more than 50 years >>now. The ship for changing it has sailed. What is one left to >>do, besides acknowledging it as a wart on the face of the >>langauge? > >I, on the other hand, don't consider it a mistake, in the >context of the C and C++ languages. I've used the ability to >fall through in a significant fraction (50% in some applications) of >the switch statements that I've written over the last >five decades of C and C++programming. Yeah, that's why I'm waffling by only "kinda sorta" agreeing, while means I'm also "kinda sorta" disagreeing. :-D Personally, I think that the BCPL `valof`/`resultis` thing is pretty cool and would have liked to see something like that in C, which in many ways would have subsumed this and other issues. But I honestly doubt they could have fit that into a C compiler meant to run on a PDP-11/20. >Absent other changes to the syntax (e.g. non-contiguous ranges >in the case selector[*]) the requirement to use break to avoid >falling through to other cases is rather valuable to me. I, too, would have liked to have seen ranges and mulitiple case values, at least. Rust has this, and it is genuinely useful. You can even do something analogous to duff's device in Rust, but it's hideous: https://huonw.github.io/blog/2025/03/rust-fallthrough/ Man, that sure looks like it got whacked by an ugly-stick, don't it? - Dan C.
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Mon, 12 Oct 2026 23:14
Date: Mon, 12 Oct 2026 23:14
27 lines
2633 bytes
2633 bytes
bart <bc@freeuk.com> writes:
> On 12/10/2026 06:22, David Brown wrote:
>> On 12/10/2026 00:05, bart wrote:
>>> So you don't really get it. That's fine.
>>>
>> So now you can drop it, along with all your other complaints about
>> the C language and tools people use with it?
>
> My opinions haven't changed at all. KT doesn't care because he doesn't
> understand the importance of having properly designed
> features. Probably he hasn't been involved in having to process
> somebody else's source code or having to translate it or port it.
I've speculated here about your motivations, so I suppose it's fair
that you speculate about mine.
You're completely wrong.
If someone doesn't agree with you, it's not necessarily because they
don't understand something fundamental. It could be because they're
right and you're wrong. You don't seem to consider that possibility.
[...]
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Mon, 12 Oct 2026 23:29
Date: Mon, 12 Oct 2026 23:29
21 lines
2196 bytes
2196 bytes
bart <bc@freeuk.com> writes:
[...]
> So 99% of programmers have to suffer needing to pointlessly write
> 'break' everywhere, rather than the 1% having to write 'fallthru'.
We're not suffering.
Speaking for myself, I had to learn *once*, several decades ago,
that each case needs to end with "break;" (unless I want fallthrough
behavior). As I've mentioned here before, I pretend that the "break;"
is part of the syntax of a switch statement, while being aware that
it really isn't.
It's easy, and it doesn't hurt a bit. I'll bet it would be easy
for you if (a) you regularly wrote C code (I don't know how often
you do) and (b) you didn't go out of your way to suffer on other
people's behalf.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Mon, 12 Oct 2026 23:43
Date: Mon, 12 Oct 2026 23:43
9 lines
2034 bytes
2034 bytes
bart <bc@freeuk.com> writes:
[...]
> Yeah, I think now we're done.
Promise?
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Mon, 12 Oct 2026 23:45
Date: Mon, 12 Oct 2026 23:45
10 lines
2139 bytes
2139 bytes
bart <bc@freeuk.com> writes:
[...]
> Yeah, I think now we're done.
You've posted 5 more articles in this thread after the above.
Does "done" mean something else in your language?
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: Dan Cross
Date: Mon, 12 Oct 2026 23:46
Date: Mon, 12 Oct 2026 23:46
16 lines
1415 bytes
1415 bytes
In article <11ajrf0$28f2$4@kst.eternal-september.org>, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >bart <bc@freeuk.com> writes: >[...] >> Yeah, I think now we're done. > >You've posted 5 more articles in this thread after the above. >Does "done" mean something else in your language? It's how you terminate the scope introduced by a looping construct in bart's language; it doesn't mean that the loop is finished iterating. ;-P - Dan C.
Re: Taming The Switch-Statement
Author: bart
Date: Mon, 12 Oct 2026 23:53
Date: Mon, 12 Oct 2026 23:53
53 lines
3349 bytes
3349 bytes
On 13/10/2026 00:29, Keith Thompson wrote:
> bart <bc@freeuk.com> writes:
> [...]
>> So 99% of programmers have to suffer needing to pointlessly write
>> 'break' everywhere, rather than the 1% having to write 'fallthru'.
>
> We're not suffering.
>
I was replying to SL who doesn't think auto-fall-through is a mistake
because he uses it a lot. Even though he says this:
"I've used the ability to fall through in a significant fraction (50% in
some applications) of the switch statements"
So 50% /sometimes/, and not even individual case-blocks, but of those
switch statements which use at least one fall-through, if I read that right.
So even for him, the majority of case-labels do not fall through.
That makes it rather strange to favour the minority case when it would
be more convenient and less typing for everybody, including SL, if it
was the other way around!
> Speaking for myself, I had to learn *once*, several decades ago,
> that each case needs to end with "break;" (unless I want fallthrough
> behavior). As I've mentioned here before, I pretend that the "break;"
> is part of the syntax of a switch statement, while being aware that
> it really isn't.
>
> It's easy, and it doesn't hurt a bit. I'll bet it would be easy
> for you if (a) you regularly wrote C code (I don't know how often
> you do) and (b) you didn't go out of your way to suffer on other
> people's behalf.
>
This is what I suggested in my first reply in the thread:
break; case a: case b:
break; case c:
break; default:;
That is, use 'break; case' for the first case label of a block.
And also:
"Alternately, create a macro like 'endcase' that expands to 'break', for
a more structured appearance."
These are practical workarounds. That 'break; case' was part of a
solution I used for a 20Kloc C application.
Re: Taming The Switch-Statement
Author: bart
Date: Mon, 12 Oct 2026 23:56
Date: Mon, 12 Oct 2026 23:56
11 lines
2295 bytes
2295 bytes
On 13/10/2026 00:45, Keith Thompson wrote: > bart <bc@freeuk.com> writes: > [...] >> Yeah, I think now we're done. > > You've posted 5 more articles in this thread after the above. > Does "done" mean something else in your language? > Other people than David Brown post remarks and it is polite to respond. As I did to you a few minutes ago.
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Tue, 13 Oct 2026 00:02
Date: Tue, 13 Oct 2026 00:02
70 lines
3923 bytes
3923 bytes
bart <bc@freeuk.com> writes:
[...]
> That's what it seems like: obstinately trying to pretend it is not a
> flaw, that it makes perfect sense, then you never want to do any of
> the stuff where it causes problems anyway etc.
Nobody is trying to pretend that there are no flaws. The rest of
us acknowledge that C has flaws (though we don't necessarily agree
with what those flaws are) and then get on with writing working C
code in spite of those flaws.
Most of us are also aware of how very difficult it would be to "fix"
those flaws without breaking existing code.
You completely misunderstand where most of us are coming from,
even after it's explained to you.
> There are several issues discussed regarding switch:
>
> * That its structure is totally chaotic (there /is/ no structure)
An overstatement, but I don't entirely disagree. switch is a low-level
control structure. I'd say it's notable for its low-levelness even
compared to other C features.
> * That 'break' is needed to escape from the middle of that statement to
> the end
Yes. We all know that.
> * That that 'break' happens also to clash, needlessly, with loop-break
Yes, we all know that. BCPL had BREAK and ENDCASE. B apparently
dropped both, and then re-added just BREAK. C inherited break
from B. I haven't seen anyone say that that wasn't a mistake.
We just don't spend decades worrying about it.
Tell me, have this ever been a problem for you personally? Have
you ever written a switch statement nested in a loop and wanted to
break out of the loop from within the switch? (In C; I'm not asking
about your experience with other langauges.) How much difficulty
has it really cause for you?
> * And also with 'case' only doing one label at a time, instead of
> being able to do, for example: 'case a, b, c:' or 'case x...y',
> although some of this is taken care of via extensions.
"case a, b, c:" is written as "case a: case b: case c:". It's a little
more verbose than it needs to be. It's very mildly annoying.
As for "case x...y", that's already proposed for C2Y, and is
documented in the N3886 draft. You continue to whine about problems
that have already been solved.
> There's quite a lot that could have been done much better!
So invent a time machine and tell Dennis Ritchie to do it your way.
[...]
> Defending every shortcoming or quirk to the death seems common
> here.
No, it isn't.
[...]
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Tue, 13 Oct 2026 00:33
Date: Tue, 13 Oct 2026 00:33
50 lines
3255 bytes
3255 bytes
bart <bc@freeuk.com> writes:
[...]
> This is my first example expressed in C (note those first three args
> are passed by reference):
>
> while (pmtype = nextcmdparam(¶mno, &name, &value, "m") {
> switch (pmtype)
> case pm_option: ...; break;
> case pm_sourcefile:
> if (passlevel == run_pass || passlevel == runpcl_pass) {
> break;
>
> Except I can't use break like that. So I have to find a workaround.
The code appears to be valid C that doesn't do what you want. I can't
easily tell what you want it to do. I don't know which of the two break
statements was intended to break out of the loop. A comment would have
solved that.
I'm going to guess that the first break is supposed to apply to the
switch statement, and the second to the while loop.
You want the language to be changed to make this kind of thing easier.
That's already happening. If you take a look at the N3886 working
draft for C2y, it has named break statements. In C2y (or in gcc
if you use an extension), the above could be written as:
WHILE:
while (pmtype = nextcmdparam(¶mno, &name, &value, "m") {
SWITCH:
switch (pmtype)
case pm_option: ...; break SWITCH;
case pm_sourcefile:
if (passlevel == run_pass || passlevel == runpcl_pass) {
break WHILE;
assuming it's the second "break' that's supposed to break out of
the loop. (I'd probably use more meaninful names.)
There is already a solution for the problem you're complaining about.
(It also solves the problem of breaking out of nested loops.)
If you're unable to use this feature, you can use goto. That's not
ideal, but with well chosen label names and no backward branching
it's not too bad.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: bart
Date: Tue, 13 Oct 2026 00:53
Date: Tue, 13 Oct 2026 00:53
37 lines
2723 bytes
2723 bytes
On 13/10/2026 01:02, Keith Thompson wrote: > bart <bc@freeuk.com> writes: > [...] > Tell me, have this ever been a problem for you personally? It's the bigger picture that is more the problem. And yes it has affected me as I've never been able to adopt C as my main language. I guess I was too spoilt. But it isn't really about me - decisions in the language, how tools work and so on affect everyone. And yes, discussing PL design is interesting to me - there's so much going on here! > Have > you ever written a switch statement nested in a loop and wanted to > break out of the loop from within the switch? (In C; I'm not asking > about your experience with other langauges.) How much difficulty > has it really cause for you? Yes. I had to use 'goto'. I don't mind using goto when necessary but here it shouldn't have been. >> * And also with 'case' only doing one label at a time, instead of >> being able to do, for example: 'case a, b, c:' or 'case x...y', >> although some of this is taken care of via extensions. > > "case a, b, c:" is written as "case a: case b: case c:". It's a little > more verbose than it needs to be. It's very mildly annoying. It is quite annoying and a distraction. A lot more to mistype too.
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Tue, 13 Oct 2026 01:14
Date: Tue, 13 Oct 2026 01:14
64 lines
3865 bytes
3865 bytes
bart <bc@freeuk.com> writes:
> On 13/10/2026 00:29, Keith Thompson wrote:
>> bart <bc@freeuk.com> writes:
>> [...]
>>> So 99% of programmers have to suffer needing to pointlessly write
>>> 'break' everywhere, rather than the 1% having to write 'fallthru'.
>> We're not suffering.
>
> I was replying to SL who doesn't think auto-fall-through is a mistake
> because he uses it a lot.
[...]
And I was replying to your deeply silly claim that 99% of C programmers
"suffer" because we need to use "break" in switch statements.
[...]
> That makes it rather strange to favour the minority case when it would
> be more convenient and less typing for everybody, including SL, if it
> was the other way around!
Sure, it's strange. A small minority of C programmers might prefer
to have fallthrough as the default. The majority, I suspect, *would
have* preferred not to have fallthrough as the default.
Nobody other than you, as far as I can tell, thinks that the strange
choice made several decades ago has led to mass suffering.
[...]
> This is what I suggested in my first reply in the thread:
>
> break; case a: case b:
> break; case c:
> break; default:;
>
> That is, use 'break; case' for the first case label of a block.
Yes, I suppose that would work, but frankly it looks weird. If
you want to use that pattern in your own code, nobody is going to
stop you. It reminds me of "Yoda conditions" (if (42 == x)), an
ugly coding practice that might make it slightly easier to avoid
a certain kind of error.
> And also:
>
> "Alternately, create a macro like 'endcase' that expands to 'break',
> for a more structured appearance."
All C programmers know that "break;" is how you terminate a case
if you don't want fallthrough. A macro that expands to "break"
doesn't help anything. I have to look up the definition to be sure
it's not doing something weird, and it doesn't address any of the
problems you've been complaining about. And of course you still
have to remember that "break" in a switch in a loop doesn't break
out of the loop. It appears to be an attempt to make C look like
some other language, something I've never found to be a good idea.
But again, if you want to use your "endcase" macro, nobody will
stop you.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Tue, 13 Oct 2026 01:54
Date: Tue, 13 Oct 2026 01:54
19 lines
2164 bytes
2164 bytes
On 2026-10-13 02:02, Keith Thompson wrote: > bart <bc@freeuk.com> writes: > [...] >> There are several issues discussed regarding switch: >> * That its structure is totally chaotic (there /is/ no structure) > > An overstatement, but I don't entirely disagree. switch is a low-level > control structure. I'd say it's notable for its low-levelness even > compared to other C features. I'm a bit astonished about that statement. The [original] "C" control structures appear to me to be all low-level; if I see "for (..;..;..)" it doesn't really strike me with awe concerning its abstraction level. And 'for' is the "most complex", the others are even more primitive. Janis > [...]
Re: Taming The Switch-Statement
Author: Waldek Hebisch
Date: Tue, 13 Oct 2026 07:23
Date: Tue, 13 Oct 2026 07:23
82 lines
5008 bytes
5008 bytes
Michael S <already5chosen@yahoo.com> wrote:
> On Mon, 12 Oct 2026 21:09:25 +0200
> David Brown <david.brown@hesbynett.no> wrote:
>
>> On 12/10/2026 21:02, Michael S wrote:
>> > On Sun, 11 Oct 2026 14:28:29 -0700
>> > Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> >
>> >> bart <bc@freeuk.com> writes:
>> >> [...]
>> >>> 'break' to quit a loop early is part of the language, so why
>> >>> shouldn't someone make use it?
>> >>
>> >> Agreed. (There are coding styles that require loops to exit only
>> >> at the bottom, but that's not what we're talking about.)
>> >>
>> >>> It just its use can be interfered with when 'switch' is involved.
>> >>>
>> >>
>> >> Yes. Everyone here knows that, and knew it before you started
>> >> talking about it.
>> >>
>> >> Michael S wrote above that "The cases where I want to break out of
>> >> the loop from the switch in the body of the loop are very common."
>> >> Tim Rentsch questioned the "very common" part of that, and asked
>> >> for an example. You jumped in and asserted that an example isn't
>> >> necessary, because you misunderstood what was being said.
>> >>
>> >
>> > I didn't read the whole subthread, but from what I read it seems
>> > that the only reader that misunderstood my statement was David
>> > Brown. The rest, including bart, understood just fine.
>> >
>>
>> If I have misunderstood, I would love to be corrected. In a number
>> of my posts I said I was not sure what you were talking about, and
>> would need more explanation.
>>
>
> I thought that my comment is hard to misunderstand, but you proved
> me wrong. So I'd try to elaborate:
>
> switch() nested within loop is very common in my practice and I suppose
> in practice of everybody else.
>
> In my practice, but obviously not in practice of Tim Rentsch, it
> is sufficiently common to want to transfer control from point within
> such nested switch to point immediately following the containing loop.
>
> If break out of loop and break out of switch were different keyword, it
> would be very easy to do.
>
> But since the keyword is shared I have to use workarounds. Many of them
> were mentioned in the sub-thread. All workarounds work. They are all
> less simple and less elegant than what would have been possible if break
> keyword was not shared.
I think there is still not clear what "common" in your text above
means. To clarify a bit, I have a non-C codebase where one can
use 'break' within equivalent of 'switch'. My gut feelings were
that such use is reasonably common (I certainly remeber such uses
in the codebase). But counting kerwords shows that I have 6053
occurences of keyword indicating loop (some may be in comments,
but that should not affect statistics too much), 223 occurences
of 'break', 197 occurences of equivalet of 'continue', 2390
occurences of 'return'. In this language 'return' is only
used for ealy returns, otherwise last value computed (which
may be void) is returned.
So what those counts indicate: majority of loops is simple, that
is have no early exit. Vast majority of early exits is done
via 'return'. "Interesting" loop control is relatively rare.
Checking which 'break'-s are within equivalent of 'switch' would
require manual inspection and that would be too much work. But
reasonable guestimate to that there are tens such uses. In
a sense that is common, that is significantly more than one
case. If my guestimate is correct, then this may be nontrivial
fraction of all uses of 'break'. OTOH that is tiny fraction
of all loops.
--
Waldek Hebisch
Re: Taming The Switch-Statement
Author: David Brown
Date: Tue, 13 Oct 2026 07:27
Date: Tue, 13 Oct 2026 07:27
55 lines
3385 bytes
3385 bytes
On 12/10/2026 23:46, bart wrote:
> On 12/10/2026 22:21, Scott Lurndal wrote:
>
>> In any case, using goto to leave a switch statement nested
>> in a loop is certainly an idiomatic construct that is widely
>> used to leave the outer loop early. Another option is to declare
>> a local bool before the switch in the while loop, initialized to false.
>>
>> Set it to true when you want to bail early:
>>
>> while (condition)
>> bool bail = false;
>> switch (blah) {
>> case 1:
>> break;
>> case 2:
>> if (fred == name) bail = true;
>> break;
>> }
>> if (bail) break;
>> do_something();
>> }
Alternatively :
bool looping = true;
while (looping && condition)
switch (blah) {
case 1:
break;
case 2:
if (fred == name) looping = false;
break;
}
do_something();
}
(The semantics for when "do_something()" is called is slightly different
here, but that depends on what something you want to do.)
Or you put your loop in a function - and then "return" breaks out of
everything. There are plenty of ways to structure the code.
Like every programming language, C provides some features and not
others. You use the features the language has in the way that gives the
best results for your code. There are /always/ going to be some
mismatches - features that you think are unnecessary, and things that
you think would be convenient if they existed. No two programmers are
going to agree on those mismatches, though they might have some overlap
of opinion.
Trying to invent a new special syntax just for one particular use-case
is absurd. It might make sense in a little private language, but not
for a mainstream programming language.
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Tue, 13 Oct 2026 10:12
Date: Tue, 13 Oct 2026 10:12
43 lines
3383 bytes
3383 bytes
On 2026-10-13 09:23, Waldek Hebisch wrote:
> [...]
> So what those counts indicate: majority of loops is simple, that
> is have no early exit. Vast majority of early exits is done
> via 'return'. "Interesting" loop control is relatively rare.
> Checking which 'break'-s are within equivalent of 'switch' would
> require manual inspection and that would be too much work. But
> reasonable guestimate to that there are tens such uses. In
> a sense that is common, that is significantly more than one
> case. If my guestimate is correct, then this may be nontrivial
> fraction of all uses of 'break'. OTOH that is tiny fraction
> of all loops.
From my (personal) perspective, I commonly have two types of
such specific constructs; a very common one is iterating over
options
while ((opt = getopts (...)) != -1)
switch (opt) ...
where, of course, and quite naturally, always the whole loop
is iterated, with no early leaving. And the second common loop
type is those where the switched data comes from the function
as well
while ((token = parse (...)) != END_TOKEN)
switch (token) ...
I'm aware that one might wants to pass and process two values
from a function (as I interpreted one of bart's recent code
fragments), but then, and if it would be "impossible" to avoid
that pattern, I'd just add a condition
int leaving = 0;
while ((token = parse (&token...)) != ERROR && !leaving)
switch (token)
case END_TOKEN: leaving = 1; ...
that's really trivial and straightforward, and it's beyond me
why anyone (but bart, of course) would see a problem here.
Janis
Re: Taming The Switch-Statement
Author: bart
Date: Tue, 13 Oct 2026 10:16
Date: Tue, 13 Oct 2026 10:16
83 lines
5339 bytes
5339 bytes
On 13/10/2026 08:23, Waldek Hebisch wrote: > Michael S <already5chosen@yahoo.com> wrote: >> I thought that my comment is hard to misunderstand, but you proved >> me wrong. So I'd try to elaborate: >> >> switch() nested within loop is very common in my practice and I suppose >> in practice of everybody else. >> >> In my practice, but obviously not in practice of Tim Rentsch, it >> is sufficiently common to want to transfer control from point within >> such nested switch to point immediately following the containing loop. >> >> If break out of loop and break out of switch were different keyword, it >> would be very easy to do. >> >> But since the keyword is shared I have to use workarounds. Many of them >> were mentioned in the sub-thread. All workarounds work. They are all >> less simple and less elegant than what would have been possible if break >> keyword was not shared. > > I think there is still not clear what "common" in your text above > means. To clarify a bit, I have a non-C codebase where one can > use 'break' within equivalent of 'switch'. My gut feelings were > that such use is reasonably common (I certainly remeber such uses > in the codebase). But counting kerwords shows that I have 6053 > occurences of keyword indicating loop (some may be in comments, > but that should not affect statistics too much), 223 occurences > of 'break', 197 occurences of equivalet of 'continue', 2390 > occurences of 'return'. In this language 'return' is only > used for ealy returns, otherwise last value computed (which > may be void) is returned. > > So what those counts indicate: majority of loops is simple, that > is have no early exit. Vast majority of early exits is done > via 'return'. "Interesting" loop control is relatively rare. > Checking which 'break'-s are within equivalent of 'switch' would > require manual inspection and that would be too much work. But > reasonable guestimate to that there are tens such uses. In > a sense that is common, that is significantly more than one > case. If my guestimate is correct, then this may be nontrivial > fraction of all uses of 'break'. OTOH that is tiny fraction > of all loops. These are my stats across 3 of my non-C non-scripting apps, some 80Kloc (other apps share modules so would duplicate): Loops 997 Exit (1 level) 257 (ie. 'break' in C) Exit (All levels) 4 Exit (other) 0 Switch 814 (Looping switch 33 included also in Loops and Switch counts) Explicit return 1920 (Non-early returns are optional) So on average, 25% of all loops have early exits (your figures show about 4%). There's no analysis of whether they are inside switch or whatever, but observation yesterday suggested it was common. Switch is used so heavily (and there is Looping Switch which needs an explicit way to terminate!) then it's likely it is all mixed up. This is really the point - it shouldn't be necessary to care. The point has been made several times that loop-break clashing with switch-break is no different from a multi-level loop break (or even a multi-level switch break, whatever that even means). Well, it /is/ very different, and in my code-base, is infrequent. This is just playing down the consequences of the choices made in C. They are not serious, but they are not ideal, nor elegant, and involve workarounds that are a distraction. People should also be able to want to break out of enclosing loops from inside 'switch' without having to defend their choices!
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Tue, 13 Oct 2026 10:18
Date: Tue, 13 Oct 2026 10:18
17 lines
2049 bytes
2049 bytes
On 2026-10-13 09:27, David Brown wrote: > [...] > > Trying to invent a new special syntax just for one particular use-case > is absurd. That's the point! > It might make sense in a little private language, but not > for a mainstream programming language. Such dubious designs might not even make sense in a "private language"; but no one would notice such a design decision, and that is the crucial (and positive) aspect of "private languages". Janis
Re: Taming The Switch-Statement
Author: bart
Date: Tue, 13 Oct 2026 10:26
Date: Tue, 13 Oct 2026 10:26
51 lines
3873 bytes
3873 bytes
On 13/10/2026 11:12, Janis Papanagnou wrote: > On 2026-10-13 09:23, Waldek Hebisch wrote: >> [...] >> So what those counts indicate: majority of loops is simple, that >> is have no early exit. Vast majority of early exits is done >> via 'return'. "Interesting" loop control is relatively rare. >> Checking which 'break'-s are within equivalent of 'switch' would >> require manual inspection and that would be too much work. But >> reasonable guestimate to that there are tens such uses. In >> a sense that is common, that is significantly more than one >> case. If my guestimate is correct, then this may be nontrivial >> fraction of all uses of 'break'. OTOH that is tiny fraction >> of all loops. > > From my (personal) perspective, I commonly have two types of > such specific constructs; a very common one is iterating over > options > > while ((opt = getopts (...)) != -1) > switch (opt) ... > > where, of course, and quite naturally, always the whole loop > is iterated, with no early leaving. And the second common loop > type is those where the switched data comes from the function > as well > > while ((token = parse (...)) != END_TOKEN) > switch (token) ... > > I'm aware that one might wants to pass and process two values > from a function (as I interpreted one of bart's recent code > fragments), but then, and if it would be "impossible" to avoid > that pattern, I'd just add a condition > > int leaving = 0; > while ((token = parse (&token...)) != ERROR && !leaving) > switch (token) > case END_TOKEN: leaving = 1; ... > > that's really trivial and straightforward, and it's beyond me > why anyone (but bart, of course) would see a problem here. Because it's a hack. But if this is acceptable, then why does C even have loop-break? Since there is always some workaround (or 'writing code' as David Brown puts it.) What would be the consequences of C not having it: would they be positive or negative overall? Now apply the same analysis to a hypothetical loop-break that works inside switch.
Re: Taming The Switch-Statement
Author: bart
Date: Tue, 13 Oct 2026 10:33
Date: Tue, 13 Oct 2026 10:33
70 lines
4149 bytes
4149 bytes
On 13/10/2026 08:27, David Brown wrote:
> On 12/10/2026 23:46, bart wrote:
>> On 12/10/2026 22:21, Scott Lurndal wrote:
>>
>>> In any case, using goto to leave a switch statement nested
>>> in a loop is certainly an idiomatic construct that is widely
>>> used to leave the outer loop early. Another option is to declare
>>> a local bool before the switch in the while loop, initialized to false.
>>>
>>> Set it to true when you want to bail early:
>>>
>>> while (condition)
>>> bool bail = false;
>>> switch (blah) {
>>> case 1:
>>> break;
>>> case 2:
>>> if (fred == name) bail = true;
>>> break;
>>> }
>>> if (bail) break;
>>> do_something();
>>> }
>
> Alternatively :
>
> bool looping = true;
> while (looping && condition)
> switch (blah) {
> case 1:
> break;
> case 2:
> if (fred == name) looping = false;
> break;
> }
> do_something();
> }
>
> (The semantics for when "do_something()" is called is slightly different
> here, but that depends on what something you want to do.)
>
> Or you put your loop in a function - and then "return" breaks out of
> everything. There are plenty of ways to structure the code.
Sometimes you just want to write the simplest, more direct and most
intuitive code.
/Having/ to invent functions, and a special interface, to get around a
language issue is always a code smell.
> Like every programming language, C provides some features and not
> others. You use the features the language has in the way that gives the
> best results for your code. There are /always/ going to be some
> mismatches - features that you think are unnecessary, and things that
> you think would be convenient if they existed. No two programmers are
> going to agree on those mismatches, though they might have some overlap
> of opinion.
>
> Trying to invent a new special syntax just for one particular use-case
> is absurd. It might make sense in a little private language, but not
> for a mainstream programming language.
In my language (and others which don't have C's quirk) there is no
special syntax needed. You just write 'exit' or 'break', as the case may
be, oblivious to whether you are inside switch or not.
This is less 'cognitive load' than the calamity of having one extra
keyword, that C would have needed.
Re: Taming The Switch-Statement
Author: Dan Cross
Date: Tue, 13 Oct 2026 10:52
Date: Tue, 13 Oct 2026 10:52
49 lines
3134 bytes
3134 bytes
In article <11ajsfi$28f2$5@kst.eternal-september.org>, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >[snip] >Yes, we all know that. BCPL had BREAK and ENDCASE. B apparently >dropped both, and then re-added just BREAK. C inherited break >from B. I haven't seen anyone say that that wasn't a mistake. >We just don't spend decades worrying about it. A minor historical quibble: BCPL, at the time of C's invention, did not have `ENDCASE`; that came later. We tend to forget that BCPL did not stop evolving after C's invention; in fact, it went on as a going concern for quite a few more years. From Dennis Ritchie's HOPL paper: |Not every difference between the BCPL language documented in |Richards's book [Richards 79] and B was deliberate; we started |from an earlier version of BCPL [Richards 67]. For example, the |`endcase` that escapes from a BCPL `switchon` statement was not |present in the language when we learned it in the 1960s, and so |the overloading of the `break` keyword to escape from the B and |C `switch` statement owes to divergent evolution rather than |conscious change. (https://www.nokia.com/bell-labs/about/dennis-m-ritchie/chist.html) Note this is the only place in that paper where Dennis Ritchie mentions `break`. Why was it overloaded for `switch`? He does not say, exactly, but he _does_ alude to space being a consideration for B, and some of the resulting syntactic quirks then escaping into C: |Storage limitations on the B compiler demanded a one-pass |technique in which output was generated as soon as possible, |and the syntactic redesign that made this possible was carried |forward into C. This is from a section discussing why C did not implement the, `valof`/`resultis` mechanism of BCPL: BCPL parsed the whole program into memory and operated on the parsed representation; B could not afford that luxury. Btw, one hypothesizes that some of the subsequent evolution of BCPL came from C influence; BCPL added the PL/1-style `/* ... */` comments, and it wouldn't surprise me if `ENDCASE` came from C's `break` inside of a `switch`, though I have no evidence of that. - Dan C.
Re: Taming The Switch-Statement
Author: Richard Harnden
Date: Tue, 13 Oct 2026 11:10
Date: Tue, 13 Oct 2026 11:10
64 lines
4487 bytes
4487 bytes
On 13/10/2026 11:26, bart wrote: > On 13/10/2026 11:12, Janis Papanagnou wrote: >> On 2026-10-13 09:23, Waldek Hebisch wrote: >>> [...] >>> So what those counts indicate: majority of loops is simple, that >>> is have no early exit. Vast majority of early exits is done >>> via 'return'. "Interesting" loop control is relatively rare. >>> Checking which 'break'-s are within equivalent of 'switch' would >>> require manual inspection and that would be too much work. But >>> reasonable guestimate to that there are tens such uses. In >>> a sense that is common, that is significantly more than one >>> case. If my guestimate is correct, then this may be nontrivial >>> fraction of all uses of 'break'. OTOH that is tiny fraction >>> of all loops. >> >> From my (personal) perspective, I commonly have two types of >> such specific constructs; a very common one is iterating over >> options >> >> while ((opt = getopts (...)) != -1) >> switch (opt) ... >> >> where, of course, and quite naturally, always the whole loop >> is iterated, with no early leaving. And the second common loop >> type is those where the switched data comes from the function >> as well >> >> while ((token = parse (...)) != END_TOKEN) >> switch (token) ... >> >> I'm aware that one might wants to pass and process two values >> from a function (as I interpreted one of bart's recent code >> fragments), but then, and if it would be "impossible" to avoid >> that pattern, I'd just add a condition >> >> int leaving = 0; >> while ((token = parse (&token...)) != ERROR && !leaving) >> switch (token) >> case END_TOKEN: leaving = 1; ... >> >> that's really trivial and straightforward, and it's beyond me >> why anyone (but bart, of course) would see a problem here. > Because it's a hack. But if this is acceptable, then why does C even > have loop-break? Since there is always some workaround (or 'writing > code' as David Brown puts it.) > > What would be the consequences of C not having it: would they be > positive or negative overall? > > Now apply the same analysis to a hypothetical loop-break that works > inside switch. > You could argue that 'break' is just syntactical sugar for 'goto label'. If you want to break out of multiple levels, then just use a goto. Some people have a pathological hatred of 'goto', sure. There's alway a way to avoid goto, if that's what you really want. That the code, and it's intention, is clear is the important thing. I really don't see the issue. It's a style thing at most.
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Tue, 13 Oct 2026 11:33
Date: Tue, 13 Oct 2026 11:33
91 lines
5977 bytes
5977 bytes
On 2026-10-13 12:26, bart wrote:
> On 13/10/2026 11:12, Janis Papanagnou wrote:
>> [...]
>> I'm aware that one might wants to pass and process two values
>> from a function (as I interpreted one of bart's recent code
>> fragments), but then, and if it would be "impossible" to avoid
>> that pattern, I'd just add a condition
>>
>> int leaving = 0;
>> while ((token = parse (&token...)) != ERROR && !leaving)
>> switch (token)
>> case END_TOKEN: leaving = 1; ...
I just wrote that down without thinking, so I take the opportunity
to correct that. In practice you would better swap the conditions
and name the return code variable correctly
while (!leaving && (rc = parse (&token...)) != ERROR)
>>
>> that's really trivial and straightforward, and it's beyond me
>> why anyone (but bart, of course) would see a problem here.
>
> Because it's a hack.
Your "definitions" are generally very peculiar, and they regularly
have been considered here to not reflect what typical sane people
would say about standard code patterns and programming. - I can
only explain your personal valuation if I assume that your thinking
is working in an extremely narrow corridor.
> But if this is acceptable, then why does C even
> have loop-break? Since there is always some workaround (or 'writing
> code' as David Brown puts it.)
This has already been explained so often, implicitly and explicitly,
that I don't know why you're asking it again and again. - Are you
really interested to hear all that again?! - Your perception and
comprehension appears to be like a human /dev/null. - Okay, again...
There are two principal and common "operation modes" with branches
of switch-like constructs; to leave after the the tagged commands
have been processed or to continue with the subsequent commands
("fall-through"). Various (also historic) languages do not support
a fall-through but have even more limits on their counterpart of
switch. The "C" designers decided to support both. Being a low-level
language they designed it with primitive semantics but to allow full
expressive flexibility. There are a few options how to distinguish
the switch "operation-modes". Some languages indicated both cases
(Kornshell, for example with ';;' and ';&' respectively). "C" has
decided to indicate syntactically just one of the cases explicitly,
_the case when the linear control flow is disrupted_; that thought
makes also sense since it matches the other possible "jumps", that
are existing with 'continue', 'return', 'exit()', 'goto'.
This should (again) explain what you asked with your question. (But
we also know that you aren't really interested in the answer; your
questions are obviously and mostly just your expression of "I don't
like the situation with C".)
>
> What would be the consequences of C not having it: would they be
> positive or negative overall?
Before I "met" you, bart, I would have guessed that any other
choice of implementation of 'switch' in "C" would not have made
and significant difference. Now I'd say, if the design would have
been different then it would be much better, since then we could
spare us all the pointless posts with you. (But of course you'd
then find other complaints and in practice nothing would change
anyway.)
>
> Now apply the same analysis to a hypothetical loop-break that works
> inside switch.
I (and others) have explicitly answered that in other posts. - I'm
sorry that you were incapable of understanding those explanations.
No; I won't repeat it once again. - As homework I ask you to pick
all those posts, read them, try to understand them, and create a
written summary. (By that process pupils usually learn something.)
Janis
PS: Note that I usually completely skip your posts - that's why you
only very rarely see a reply unless I see you quoted in another post
- and I've opened this post of you only because I thought you might
have commented on my little mistake above that I intended to correct.
So generally you can spare your meaningless replies to my posts and
save your (and others') time.
Re: Taming The Switch-Statement
Author: Johann 'Myrkraverk' Oskarsson
Date: Tue, 13 Oct 2026 12:04
Date: Tue, 13 Oct 2026 12:04
41 lines
3372 bytes
3372 bytes
On 10/13/2026 1:02 AM, Stefan Ram wrote:
> Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote or quoted:
>> Not to me. A giant red flag would be something akin to
>> switch ( foo ) printf( "Hello, bart\n" ) ;
>> where the printf() never gets called.
>
> GCC also flags it:
>
> main.c: In function 'main':
> main.c:3:30: warning: statement will never be executed [-Wswitch-unreachable]
> 3 | int main( void ){ switch( 0 )printf( "Hello!\n" ); }
> | ^~~~~~~~~~~~~~~~~~~~
>
> . I use, " . . . -pedantic . . . -Wall -W -Wextra -Wpedantic . . .".
You're right. And a quick and immediate silence follows if we simply
transpose the printf() and 0, as follows.
signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
We could call this refactoring maneuver /switch castle/, after the cas-
tle movement in chess.
Now GCC does /not/ complain about a useless break, unlike bart [1].
But isn't that a bug in GCC? Shouldn't a useless break have the same
diagnostic as a bypassed printf()? Like an idiotic journalist, I ask
/inquiring minds want to know/?
Best wishes, and happy /switch castle/ refactoring adventures.
[1] Or was bart complaining that the break was /not/ useless, and com-
pulsory. I'm getting a bit confused trying to follow the argument, but
it's really popcorn worthy, and I guess I'll have to order industrial
amount of it next time this comes up.
--
Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | via Easynews.com
https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
Federated at https://fed.brid.gy/bsky/myrkraverk.bsky.social
Re: Taming The Switch-Statement
Author: bart
Date: Tue, 13 Oct 2026 12:41
Date: Tue, 13 Oct 2026 12:41
96 lines
6028 bytes
6028 bytes
On 13/10/2026 12:33, Janis Papanagnou wrote:
> On 2026-10-13 12:26, bart wrote:
>> On 13/10/2026 11:12, Janis Papanagnou wrote:
>>> [...]
>>> I'm aware that one might wants to pass and process two values
>>> from a function (as I interpreted one of bart's recent code
>>> fragments), but then, and if it would be "impossible" to avoid
>>> that pattern, I'd just add a condition
>>>
>>> int leaving = 0;
>>> while ((token = parse (&token...)) != ERROR && !leaving)
>>> switch (token)
>>> case END_TOKEN: leaving = 1; ...
>
> I just wrote that down without thinking, so I take the opportunity
> to correct that. In practice you would better swap the conditions
> and name the return code variable correctly
>
> while (!leaving && (rc = parse (&token...)) != ERROR)
So your workaround had an error. That's what happens.
>>>
>>> that's really trivial and straightforward, and it's beyond me
>>> why anyone (but bart, of course) would see a problem here.
>>
>> Because it's a hack.
>
> Your "definitions" are generally very peculiar, and they regularly
> have been considered here to not reflect what typical sane people
> would say about standard code patterns and programming. - I can
> only explain your personal valuation if I assume that your thinking
> is working in an extremely narrow corridor.
Jesus. I take it that you don't agree it is a hack then?
(From Google AI: "In coding, a hack can mean a quick, inelegant
workaround to fix a problem". Other definitions are given, but this what
I have in mind.)
>> But if this is acceptable, then why does C even have loop-break? Since
>> there is always some workaround (or 'writing code' as David Brown puts
>> it.)
>
> This has already been explained so often, implicitly and explicitly,
> that I don't know why you're asking it again and again. - Are you
> really interested to hear all that again?! - Your perception and
> comprehension appears to be like a human /dev/null. - Okay, again...
Just answering my question would be fewer words!
> There are two principal and common "operation modes" with branches
> of switch-like constructs; to leave after the the tagged commands
> have been processed or to continue with the subsequent commands
> ("fall-through"). Various (also historic) languages do not support
> a fall-through but have even more limits on their counterpart of
> switch. The "C" designers decided to support both. Being a low-level
> language they designed it with primitive semantics but to allow full
> expressive flexibility. There are a few options how to distinguish
> the switch "operation-modes". Some languages indicated both cases
> (Kornshell, for example with ';;' and ';&' respectively). "C" has
> decided to indicate syntactically just one of the cases explicitly,
> _the case when the linear control flow is disrupted_; that thought
> makes also sense since it matches the other possible "jumps", that
> are existing with 'continue', 'return', 'exit()', 'goto'.
You have a peculiar, dense, machine-like writing style. I'm fairly
certain you are a real human, but this is impenetrable, sorry.
> This should (again) explain what you asked with your question. (But
> we also know that you aren't really interested in the answer; your
> questions are obviously and mostly just your expression of "I don't
> like the situation with C".)
>
>>
>> What would be the consequences of C not having it: would they be
>> positive or negative overall?
>
> Before I "met" you, bart, I would have guessed that any other
> choice of implementation of 'switch' in "C" would not have made
> and significant difference. Now I'd say, if the design would have
> been different then it would be much better, since then we could
> spare us all the pointless posts with you. (But of course you'd
> then find other complaints and in practice nothing would change
> anyway.)
If you aren't going to engage, why bother posting?
> PS: Note that I usually completely skip your posts
And I usually don't bother replying to yours since all you do is
personal insults, when I can understand what you're on about.
Re: Taming The Switch-Statement
Author: Tim Rentsch
Date: Tue, 13 Oct 2026 13:55
Date: Tue, 13 Oct 2026 13:55
72 lines
4542 bytes
4542 bytes
Richard Harnden <richard.nospam@gmail.invalid> writes: > On 13/10/2026 11:26, bart wrote: > >> On 13/10/2026 11:12, Janis Papanagnou wrote: >> >>> On 2026-10-13 09:23, Waldek Hebisch wrote: >>> >>>> [...] >>>> So what those counts indicate: majority of loops is simple, >>>> that is have no early exit. Vast majority of early exits is >>>> done via 'return'. "Interesting" loop control is relatively >>>> rare. Checking which 'break'-s are within equivalent of >>>> 'switch' would require manual inspection and that would be too >>>> much work. But reasonable guestimate to that there are tens >>>> such uses. In a sense that is common, that is significantly >>>> more than one case. If my guestimate is correct, then this may >>>> be nontrivial fraction of all uses of 'break'. OTOH that is >>>> tiny fraction of all loops. >>> >>> From my (personal) perspective, I commonly have two types of >>> such specific constructs; a very common one is iterating over >>> options >>> >>> while ((opt = getopts (...)) != -1) >>> switch (opt) ... >>> >>> where, of course, and quite naturally, always the whole loop >>> is iterated, with no early leaving. And the second common loop >>> type is those where the switched data comes from the function >>> as well >>> >>> while ((token = parse (...)) != END_TOKEN) >>> switch (token) ... >>> >>> I'm aware that one might wants to pass and process two values >>> from a function (as I interpreted one of bart's recent code >>> fragments), but then, and if it would be "impossible" to avoid >>> that pattern, I'd just add a condition >>> >>> int leaving = 0; >>> while ((token = parse (&token...)) != ERROR && !leaving) >>> switch (token) >>> case END_TOKEN: leaving = 1; ... >>> >>> that's really trivial and straightforward, and it's beyond me >>> why anyone (but bart, of course) would see a problem here. >> >> Because it's a hack. But if this is acceptable, then why does C >> even have loop-break? Since there is always some workaround (or >> 'writing code' as David Brown puts it.) >> >> What would be the consequences of C not having it: would they be >> positive or negative overall? >> >> Now apply the same analysis to a hypothetical loop-break that >> works inside switch. > > You could argue that 'break' is just syntactical sugar for > 'goto label'. > > If you want to break out of multiple levels, then just use a > goto. > > Some people have a pathological hatred of 'goto', sure. > There's alway a way to avoid goto, if that's what you really > want. That the code, and it's intention, is clear is the > important thing. > > I really don't see the issue. It's a style thing at most. Very pragmatic. This pretty much matches my sentiments.
Re: Taming The Switch-Statement
Author: Dan Cross
Date: Tue, 13 Oct 2026 14:38
Date: Tue, 13 Oct 2026 14:38
15 lines
1347 bytes
1347 bytes
In article <11al8uc$hk7a$1@dont-email.me>, bart <bc@freeuk.com> wrote: >[snip] >So your workaround had an error. That's what happens. There is no programming that prevents all errors. >[snip] >Jesus. I take it that you don't agree it is a hack then? I'll admit it's a hack, but I just don't care. It's certainly not worth expending as much effort as even this thread alone has taken. - Dan C.
Re: Taming The Switch-Statement
Author: Tim Rentsch
Date: Tue, 13 Oct 2026 14:40
Date: Tue, 13 Oct 2026 14:40
74 lines
5296 bytes
5296 bytes
Michael S <already5chosen@yahoo.com> writes: > On Mon, 12 Oct 2026 21:09:25 +0200 > David Brown <david.brown@hesbynett.no> wrote: > >> On 12/10/2026 21:02, Michael S wrote: >> >>> On Sun, 11 Oct 2026 14:28:29 -0700 >>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >>> >>>> bart <bc@freeuk.com> writes: >>>> [...] >>>> >>>>> 'break' to quit a loop early is part of the language, so why >>>>> shouldn't someone make use it? >>>> >>>> Agreed. (There are coding styles that require loops to exit only >>>> at the bottom, but that's not what we're talking about.) >>>> >>>>> It just its use can be interfered with when 'switch' is involved. >>>> >>>> Yes. Everyone here knows that, and knew it before you started >>>> talking about it. >>>> >>>> Michael S wrote above that "The cases where I want to break out of >>>> the loop from the switch in the body of the loop are very common." >>>> Tim Rentsch questioned the "very common" part of that, and asked >>>> for an example. You jumped in and asserted that an example isn't >>>> necessary, because you misunderstood what was being said. >>> >>> I didn't read the whole subthread, but from what I read it seems >>> that the only reader that misunderstood my statement was David >>> Brown. The rest, including bart, understood just fine. >> >> If I have misunderstood, I would love to be corrected. In a number >> of my posts I said I was not sure what you were talking about, and >> would need more explanation. > > I thought that my comment is hard to misunderstand, but you proved > me wrong. So I'd try to elaborate: > > switch() nested within loop is very common in my practice and I suppose > in practice of everybody else. > > In my practice, but obviously not in practice of Tim Rentsch, it > is sufficiently common to want to transfer control from point within > such nested switch to point immediately following the containing loop. Let me clarify my earlier comment. I'm not surprised that people routinely use switch() inside of loops. What did surprise me is the statement that wanting to break out of the loop from inside the switch() is "very common". Not happens occasionally; not happens commonly or even just sufficiently commonly; not happens routinely; but "very common". I am wondering now how common it actually is, for switch() in general and for switch() inside of a loop. Is it one in a hundred? One in ten? One in two? More than that? I asked for an example because I am curious about what the proximate cause of such commonality might be. Is it a general style matter? Is it that you are used to certain patterns of local control flow? Is it that some use cases are more common in the kinds of programs you deal with? It would be good to get some data here, even just ad hoc data. In my own experience, wanting to escape multiple levels (including the case of provoking a loop exit from inside a switch()) doesn't happen often enough to merit considering a language change. But I would like to know more about the experiences of other people. I'm reminded of a quote from (if memory serves) Tony Hoare, about language design. Paraphrasing: A programming language should not reflect the union of all the features proposed by its designers; rather it should reflect the union of the designers' prejudices about what features should NOT be put into the language.
Re: Taming The Switch-Statement
Author: bart
Date: Tue, 13 Oct 2026 15:46
Date: Tue, 13 Oct 2026 15:46
83 lines
5344 bytes
5344 bytes
On 13/10/2026 15:40, Tim Rentsch wrote:
> Michael S <already5chosen@yahoo.com> writes:
>
>> I thought that my comment is hard to misunderstand, but you proved
>> me wrong. So I'd try to elaborate:
>>
>> switch() nested within loop is very common in my practice and I suppose
>> in practice of everybody else.
>>
>> In my practice, but obviously not in practice of Tim Rentsch, it
>> is sufficiently common to want to transfer control from point within
>> such nested switch to point immediately following the containing loop.
>
> Let me clarify my earlier comment. I'm not surprised that people
> routinely use switch() inside of loops. What did surprise me is the
> statement that wanting to break out of the loop from inside the
> switch() is "very common". Not happens occasionally; not happens
> commonly or even just sufficiently commonly; not happens routinely;
> but "very common". I am wondering now how common it actually is,
> for switch() in general
For switch in general is not meaningful: since this is about breaking
out of a loop: a loop needs to be involved!
> and for switch() inside of a loop. Is it
> one in a hundred? One in ten? One in two? More than that?
These are some stats for 5 of my non-C projects:
All All Of which,
Project Loops Breaks Breaks inside Switch
A 538 131 72
B 438 103 62
C 412 132 58
D 216 57 34
E 47 20 7
These are averages. It is conceivable all those 72 breaks on the first
line are within one Switch statement, but it is unlikely.
I can't do the same exercise for C examples, since that language doesn't
allow breaks inside 'switch'. (All breaks I'm talking about are
loop-breaks.)
Not sure what percentages you are after: how many loops have at least
one break within switch? That might be around 1 in 7 (14%).
What proportion of all breaks are inside switch? That would be about half.
> I asked for an example because I am curious about what the proximate
> cause of such commonality might be. Is it a general style matter?
Since this is something C doesn't directly support, getting stats is
tricky. People will use workarounds and you'd have to analyse those to
try and infer what they're trying to achieve. (Humans have to do the
same exercise; that is the problem.)
My view is that using distinct keywords for loop-break and switch-break
(accepting that the language wants the latter) would have had pretty
much zero costs, but worthwhile benefits.
> In my own experience, wanting to escape multiple levels (including
> the case of provoking a loop exit from inside a switch())
No it doesn't, but this is not about that; here we just want to break
out of one loop level!
> I'm reminded of a quote from (if memory serves) Tony Hoare, about
> language design. Paraphrasing: A programming language should not
> reflect the union of all the features proposed by its designers;
> rather it should reflect the union of the designers' prejudices
> about what features should NOT be put into the language.
Perhaps C could have done without switch-break then.
A very rough survey suggests that about 1% of lines of code in a project
are purely switch-breaks. How many billions of lines of C are there...?
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Tue, 13 Oct 2026 16:04
Date: Tue, 13 Oct 2026 16:04
27 lines
2214 bytes
2214 bytes
On 2026-10-13 16:38, Dan Cross wrote: > In article <11al8uc$hk7a$1@dont-email.me>, bart <bc@freeuk.com> wrote: >> [snip] >> So your workaround had an error. That's what happens. I could foresee such a stupid response! - You're a hopeless case. Given that you've had even stupid syntax errors in your original code I'm astonished that you even dare to get into such argument. > > There is no programming that prevents all errors. (That was not even programming; it was a quick write down for the post as an example structure to explain what's to be visualized.) > >> [snip] >> Jesus. I take it that you don't agree it is a hack then? Writing a loop with a predicate that is composed by an 'and' is certainly not a "hack" but usual programming. Nowadays you learn such things in kindergarten. Janis > [...]
Re: Taming The Switch-Statement
Author: Tim Rentsch
Date: Tue, 13 Oct 2026 16:10
Date: Tue, 13 Oct 2026 16:10
32 lines
3161 bytes
3161 bytes
bart <bc@freeuk.com> writes: > On 13/10/2026 15:40, Tim Rentsch wrote: > >> Michael S <already5chosen@yahoo.com> writes: >> > > >>> I thought that my comment is hard to misunderstand, but you proved >>> me wrong. So I'd try to elaborate: >>> >>> switch() nested within loop is very common in my practice and I suppose >>> in practice of everybody else. >>> >>> In my practice, but obviously not in practice of Tim Rentsch, it >>> is sufficiently common to want to transfer control from point within >>> such nested switch to point immediately following the containing loop. >> >> Let me clarify my earlier comment. I'm not surprised that people >> routinely use switch() inside of loops. What did surprise me is the >> statement that wanting to break out of the loop from inside the >> switch() is "very common". Not happens occasionally; not happens >> commonly or even just sufficiently commonly; not happens routinely; >> but "very common". I am wondering now how common it actually is, >> for switch() in general > > For switch in general is not meaningful: since this is about breaking > out of a loop: a loop needs to be involved! Please don't make the mistake of thinking the question I am asking is the same as the question you are interested in answering.
Re: Taming The Switch-Statement
Author: bart
Date: Tue, 13 Oct 2026 17:15
Date: Tue, 13 Oct 2026 17:15
63 lines
4026 bytes
4026 bytes
On 13/10/2026 17:10, Tim Rentsch wrote: > bart <bc@freeuk.com> writes: > >> On 13/10/2026 15:40, Tim Rentsch wrote: >> >>> Michael S <already5chosen@yahoo.com> writes: >>> >> >> >>>> I thought that my comment is hard to misunderstand, but you proved >>>> me wrong. So I'd try to elaborate: >>>> >>>> switch() nested within loop is very common in my practice and I suppose >>>> in practice of everybody else. >>>> >>>> In my practice, but obviously not in practice of Tim Rentsch, it >>>> is sufficiently common to want to transfer control from point within >>>> such nested switch to point immediately following the containing loop. >>> >>> Let me clarify my earlier comment. I'm not surprised that people >>> routinely use switch() inside of loops. What did surprise me is the >>> statement that wanting to break out of the loop from inside the >>> switch() is "very common". Not happens occasionally; not happens >>> commonly or even just sufficiently commonly; not happens routinely; >>> but "very common". I am wondering now how common it actually is, >>> for switch() in general >> >> For switch in general is not meaningful: since this is about breaking >> out of a loop: a loop needs to be involved! > > Please don't make the mistake of thinking the question I am > asking is the same as the question you are interested in > answering. This is what you said: > What did surprise me is the > statement that wanting to break out of the loop from inside the > switch() is "very common". So you're talking about breaking out of a loop from inside switch? > Not happens occasionally; not happens > commonly or even just sufficiently commonly; not happens routinely; > but "very common". > I am wondering now how common it actually is, 'it' is still breaking out a loop from inside switch? > for switch() in general > and for switch() inside of a loop. So if this covers 'breaking out of a loop from inside switch', then what on earth is meant by: > for switch() in general ? Please enlighten us.
Re: Taming The Switch-Statement
Author: Stefan Ram
Date: Tue, 13 Oct 2026 17:28
Date: Tue, 13 Oct 2026 17:28
26 lines
3105 bytes
3105 bytes
Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote or quoted:
> signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
. . .
>Now GCC does /not/ complain about a useless break, unlike bart [1].
>But isn't that a bug in GCC?
With "-Wswitch-default", gcc will note that there is no "default".
One can apply "clang-tidy" to that code to get,
. . .
|main.c:3:55: warning: 'break' will never be executed
|signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
| ^
|main.c:3:55: warning: This statement is never executed
|signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
| ^
|main.c:3:55: note: This statement is never executed
|signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
| ^
. . .
, but "clang-tidy" actually is intended for C++, so one will also
get some warnings that do not apply to C programs.
Re: Taming The Switch-Statement
Author: Johann 'Myrkraverk' Oskarsson
Date: Tue, 13 Oct 2026 18:05
Date: Tue, 13 Oct 2026 18:05
35 lines
3361 bytes
3361 bytes
On 10/14/2026 1:28 AM, Stefan Ram wrote:
> Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote or quoted:
>> signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
> . . .
>> Now GCC does /not/ complain about a useless break, unlike bart [1].
>> But isn't that a bug in GCC?
>
> With "-Wswitch-default", gcc will note that there is no "default".
>
> One can apply "clang-tidy" to that code to get,
>
> . . .
> |main.c:3:55: warning: 'break' will never be executed
> |signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
> | ^
> |main.c:3:55: warning: This statement is never executed
> |signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
> | ^
> |main.c:3:55: note: This statement is never executed
> |signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
> | ^
> . . .
>
> , but "clang-tidy" actually is intended for C++, so one will also
> get some warnings that do not apply to C programs.
Thank you. Now posters of comp.lang.c can indeed publish an issue of
the GCC magazine, and file a defect report on the behaviour of the com-
piler in the presence of a wild /break/ statement bound to an unlabelled
switch ().
--
Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | via Easynews.com
https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
Federated at https://fed.brid.gy/bsky/myrkraverk.bsky.social
Page 3 of 9 • 412 total messages
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads