🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

412 total messages Page 5 of 9 Started by Lawrence D’Oliveiro Sat, 10 Oct 2026 00:25
Page 5 of 9 • 412 total messages
Re: Taming The Switch-Statement
#431
Author: Michael S
Date: Thu, 15 Oct 2026 20:57
161 lines
7829 bytes
On Thu, 15 Oct 2026 20:42:53 -0000 (UTC)
cross@spitfire.i.gajendra.net (Dan Cross) wrote:

> In article <11aqpl3$2gdup$1@dont-email.me>, bart  <bc@freeuk.com>
> wrote:
> >On 15/10/2026 12:45, Dan Cross wrote:  
> >> In article <11aqbqv$2avn3$1@dont-email.me>, bart  <bc@freeuk.com>
> >> wrote:  
> >  
> >>> Perhaps that reused keyword thing is a bigger deal than you
> >>> think. The effect of it is unnecessary obfuscation.  
> >> 
> >> This is certainly not evidence of that.  This is just your
> >> assertion that you took a silly example and apparently (maybe?)
> >> improved it, based on some unstated, but apparently subjective,
> >> criteria.  
> >
> >I am stating that 'break' used to fix C's poor 'switch' feature 
> >interferes with 'break' used for loops.  
> 
> Sure.
> 
> >It's not even my opinion: it's fact. In your example, about a third
> >of 'break' tokens are for taking care of switch.  
> 
> Ok.
> 
> >My opinion is that it generates pointless clutter (this it would do
> >even if a different keyword was used), and it can get confusing when
> >switch and loop are mixed up.  
> 
> Ok.
> 
> >I actually took your program and ported it to my syntax, as I was 
> >curious how it would look. This is the result:
> >
> >https://github.com/bart-2026/langs/blob/main/lexertest.m
> >
> >(It's been spaced out more, vertically.)
> >
> >There were some tricky bits of the C to translate, such as:
> >
> >                         break;
> >                     default:
> >                         break;
> >                     }
> >                 default:
> >                     *tp++ = ch;
> >                     break;
> >                 }
> >             }
> >             *tp++ = '\0';
> >             tt = TkSTRING;
> >
> >where it seems to break from one switch then sneakily falls through
> >into the default clauses of the enclosing one!  
> 
> Yup.
> 
> >Well, here are some stats:
> >
> >                         C         Mine
> >
> >   Size                  3374      2997 characters (both with hard
> > tabs) Non-blank lines       210        174 Lines  
> 
> Those seem like pretty meaningless statistics.  I could really
> care less about 377 fewer bytes.  Naturally, different languages
> will express these things differently.
> 
> >I did try and run mine:
> >  
> >   c:\mapps>test  
> >   1234
> >   tok: tt = tkident, token = '1234'
> >   abc
> >   tok: tt = tkident, token = 'abc'
> >
> >It shows both of these as an identifier. But yours does the same:
> >  
> >   c:\c>a  
> >   1234
> >   tok: tt = 1003, token = '1234'
> >   abc
> >   tok: tt = 1003, token = 'abc'  
> 
> Yup.  It's a poorly written program; I am not surprised there
> are bugs.  It wasn't meant to be an illustration of exemplary
> programming, it was meant to illustrate a use case for a
> language construct that addresses a use case you appeared to
> want support for, but that are now upset about, because it was
> not provided in the way you like.  Or something.
> 
> >Whatever '1003' means, it's showing the same. So it will do (I don't 
> >care if the code is buggy, just whether my version is reasonably
> >faithful).  
> 
> This is actually a good example of the problem you often run
> into in these endless c.l.c threads: You seem to take a thing
> that was something that was only meant to show one thing, and
> asserting that it represents something other than what it was
> meant to show, and no matter how many times it is explained to
> you that it is not, in fact, what you seem to think that it is,
> you persist in your delusion and think that it proves something.
> But it doesn't, since you are starting from a false premise, at
> which point you whine that you are picked on, treated poorly,
> misunderstood, or generally dismissed, to which you conclude
> that this can only be due to a slavish devotion to C as it is,
> and a refusal to entertain that the language is not perfect.  It
> is totally lost on you that people may be objecting to what you
> are saying on its own merits, since (ironically) you don't seem
> able to admit that your own ideas may have their own
> deficiencies.
> 
> This whole discussion could be summarized as:
> 
> Bart:  "C sucks because Dennis Ritchie stupidly reused `break`
>         for both loops and switch.  He was a tasteless fool."
> All:   "You can work around that really easily."
> Keith: "C added labeled break and continue...."
> Bart:  "C sucks.  My language is better.  Here, I fixed C in 4
>         lines of code with my `breakloop`, but it still sucks
>         because C is hopeless."
> Me:    "No, the real problem is that there's no structured way
>         break out of nested contexts; your thing only addresses
>         one special case, and does not compose, so can't cover
>         the general case."
> Bart:  "No, it's the overloading.  C is terrible and you're all
>         just too blind to see it.  You are all fools, like
>         Dennis Ritchie."
> Me:    "I mean, Keith told you how the language is being changed
>         to address your problem _and_ the other problems in this
>         general category."
> Bart:  "Those other problems don't matter.  C will never change.
>         It will suck forever.  I mean, have you ever even seen a
>         use case for these labeled blocks?  I don't like them,
>         therefore they suck, just like C.  They also suck
>         because they solve a problem I don't care about.  I have
>         been doing this for 45 years."
> Me:    "Here's a program that illustrates the problem.  The code
>         is shit, but shows how it can be used...."
> Bart:  "This program sucks!  You don't _need_ to do it this
>         way."
> Me:    "...I mean, I told you it sucked when I posted it...."
> Bart:  "...I rewrote it in my language.  I saved 377 bytes.  See
>         how much C sucks now?  My language is better.
> Me:    "...."
> Bart:  "My lexer is 50% faster than your lexer.  My production
>         code is an order of magnitude faster.  I am a very smart
> 	boy, and deserve a very special gold star on my report
>         card."
> Me:    "...Bruh."
> Bart:  "Dennis Ritchie was a fool.  A fool, I say!  Haha!
>         Ahahaha! Muwhahaha!"
> 

So, you don't like Donald Trump. Most people that read comp.os.vms
already knew it.
But why do you make bart responsible for that?

Re: Taming The Switch-Statement
#434
Author: bart
Date: Thu, 15 Oct 2026 22:22
105 lines
5500 bytes
On 15/10/2026 21:42, Dan Cross wrote:
> In article <11aqpl3$2gdup$1@dont-email.me>, bart  <bc@freeuk.com> wrote:

> Those seem like pretty meaningless statistics.
> Naturally, different languages will express these things differently.

My syntax has cleaner and simpler syntax compared to C, and handles 
features like 'switch' more ergonomically. In this case, C had a 20% 
higher line count - fact.

But it seems people don't value cleaner, more productive syntax when it 
it comes to 'serious' languages, only scripting ones. OK; your loss.

> This whole discussion could be summarized as:
> 
> Bart:  "C sucks because Dennis Ritchie stupidly reused `break`
>          for both loops and switch.  He was a tasteless fool."
> All:   "You can work around that really easily."
> Keith: "C added labeled break and continue...."
> Bart:  "C sucks.  My language is better.  Here, I fixed C in 4
>          lines of code with my `breakloop`, but it still sucks
>          because C is hopeless."
> Me:    "No, the real problem is that there's no structured way
>          break out of nested contexts; your thing only addresses
>          one special case, and does not compose, so can't cover
>          the general case."
> Bart:  "No, it's the overloading.  C is terrible and you're all
>          just too blind to see it.  You are all fools, like
>          Dennis Ritchie."
> Me:    "I mean, Keith told you how the language is being changed
>          to address your problem _and_ the other problems in this
>          general category."
> Bart:  "Those other problems don't matter.  C will never change.
>          It will suck forever.  I mean, have you ever even seen a
>          use case for these labeled blocks?  I don't like them,
>          therefore they suck, just like C.  They also suck
>          because they solve a problem I don't care about.  I have
>          been doing this for 45 years."
> Me:    "Here's a program that illustrates the problem.  The code
>          is shit, but shows how it can be used...."
> Bart:  "This program sucks!  You don't _need_ to do it this
>          way."
> Me:    "...I mean, I told you it sucked when I posted it...."
> Bart:  "...I rewrote it in my language.  I saved 377 bytes.  See
>          how much C sucks now?  My language is better.
> Me:    "...."
> Bart:  "My lexer is 50% faster than your lexer.  My production
>          code is an order of magnitude faster.  I am a very smart
> 	boy, and deserve a very special gold star on my report
>          card."
> Me:    "...Bruh."



You know, I could well be right about all those points. Maybe my 
language that has been around for 45 years really is a sweeter, cleaner 
'C' which has solved most of the latter's quirks.

And maybe other people's responses to that is just sour grapes.

However one of interests is PL design - specifically at this level - and 
how C gets it so wrong, how people defend it so much, how it evolves so 
glacially, how much fixing its shortcomings is offloaded to tools, is 
fascinating.

It would have been nice to have a more objective discussion about such 
aspects, with people not afraid to be a LOT more critical of C and its 
tools that they have been.

But I guess this is the wrong forum for that.



 > Bart:  "Dennis Ritchie was a fool.  A fool, I say!  Haha!> 
Ahahaha! Muwhahaha!"

Simplest kind of function pointer:

Bart:       ref proc
DMR:        void(*)(void)

Simplest function pointer variable:

Bart:       ref proc abc
DMR:        void(*abc)(void);

Two such variables:

Bart:       ref proc one, two
DMR         void (*one)(void), (*two)void;     // I think

Two variables each an array 10 of such pointers:

Bart:       [10]ref proc one, two
DMR:        No fucking clue mate...

(Apparently it would be this, according to a tool which transpiles to C:

             void (*one[10])(void), (*two[10])(void);

Fucking hell. Actually I didn't call DMR a fool. I did mention a 
'numskull' which I now withdraw; I prefer to criticise ideas not people. 
But this is a disaster.)

Re: Taming The Switch-Statement
#438
Author: bart
Date: Fri, 16 Oct 2026 01:42
60 lines
3612 bytes
On 15/10/2026 18:10, bart wrote:
> On 15/10/2026 15:57, bart wrote:
>> On 15/10/2026 12:45, Dan Cross wrote:
>>> In article <11aqbqv$2avn3$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>>
>>>> Perhaps that reused keyword thing is a bigger deal than you think. The
>>>> effect of it is unnecessary obfuscation.
>>>
>>> This is certainly not evidence of that.  This is just your
>>> assertion that you took a silly example and apparently (maybe?)
>>> improved it, based on some unstated, but apparently subjective,
>>> criteria.
>> I am stating that 'break' used to fix C's poor 'switch' feature 
>> interferes with 'break' used for loops.
>>
>> It's not even my opinion: it's fact. In your example, about a third of 
>> 'break' tokens are for taking care of switch.
>>
>> My opinion is that it generates pointless clutter (this it would do 
>> even if a different keyword was used), and it can get confusing when 
>> switch and loop are mixed up.
>>
>> I actually took your program and ported it to my syntax, as I was 
>> curious how it would look. This is the result:
>>
>> https://github.com/bart-2026/langs/blob/main/lexertest.m
>>
>> (It's been spaced out more, vertically.)
> 
>> Well, here are some stats:
> 
>> I did try and run mine:
> Enough worked that I decided to try a speed test. Both use exactly the 
> same algorithm, and I didn't expect either to be fast.
> 
> Still, the version in my language/compiler was 50% faster than the C 
> compiled with gcc-O3. I don't know why.
I'm mildly curious about this even if no one else is (or they think it 
is some sort of boasting although I said I didn't know the reason).

I've now converted DC's C program to use normal gotos, so that I can try 
with other compilers.

For my test (10M lines of the same 8 tokens):

   gcc 16.x  28 seconds   (any opt. level)
   gcc 14.x  18 seconds
   clang-O3  18 seconds
   tcc       18 seconds
   bcc       18 seconds
   mm        18 seconds   (my lang)

Figures are pretty much at those two levels.

So it's more likely a library thing and it is i/o bound.

Anyway, I'm done with all this now; my C compiler and related apps are 
no more.

Re: Taming The Switch-Statement
#444
Author: Tim Rentsch
Date: Fri, 16 Oct 2026 10:36
75 lines
5408 bytes
Andrey Tarasevich <noone@noone.net> writes:

> On Sun 10/11/2026 6:33 AM, David Brown wrote:
>
>> It is quite obvious that it is easy to write code with loops + break
>> within a switch.  It is equally obvious that it is easy to avoid
>> such constructs - there are always ways to avoid a "break" in a
>> loop, and if the code run within a switch case is complex, it is
>> often practical to refactor it into a separate function.  But
>> presumably Michael has reasons not do do that.
>
> Um... The common pattern for a "search"-style loop looks as follows
>
>   for (/* domain condition */)
>   {
>     ...
>     if (/* search condition */)
>       break;
>     ...
>   }
>
> So, loops that terminate with `break` are the mainstay of every
> competently written code.  Moving the "early termination" condition
> into the loop header (i.e. lumping the search condition with the
> domain condition) is a very ugly anti-pattern in most cases.  Moreover,
> majority of the loops in an average C program are such "search"-style
> loops, meaning that they do have an "early termination" condition.
>
> Now, while overwhelming majority of my loops would use `if` to check
> the "early termination", I can imagine that there sill be cases where
> switch` is applicable and more appropriate than an `if`. Yes, a
> switch` can always be replaced with an `if` ladder, but being _forced_
> to do so by a language limitation doesn't look right.
>
> And writing a separate function just to work around a weird language
> limitation... that doesn't look right either.

I'm afraid I must simply flat out disagree with some of the comments
above.

Certainly it is true that many C programs use a for-if-break pattern
in some or many places.  It's fair to call it a common pattern.  But
it's wrong to say it is /the/ common pattern.  There are other ways
of skinning that cat, and I expect most C programmers have used some
or all of them in the normal course of program development.

Similarly, the assertion that "loops that terminate with `break` are
the mainstay of every competently written code" is an absurd
overstatement.  No doubt break-exiting loops are a significant part
of many programs.  Probably they are a mainstay in some of them.
But to say they are /the/ mainstay in any non-trivial program is at
best a stretch;  to assert that they are /the/ mainstay in /all/
competently written code is simply wrong.

I looked at some statistics for a couple of code bases.  The relative
amounts of switch() versus loops (for(), while(), do/while()) was
relatively constant, about one in six or one in seven.  Use of break
varied a lot, from close to six percent to under two percents (here
percent means percentage of occurrences of all control keywords).
The biggest category was if() and return, over 80% of the total and
roughly eight times the amount of looping structures.  In the scheme
of things switch() is not very important.  Loops are important.  The
more prominent if() and return are very important.  The idea that,
one, exiting a loop with break is always an essential program element
and, two, it's important to be able to do that using switch(), isn't
a good fit for the facts on the ground.

Incidentally, the comment that writing a separate function "doesn't
look right" seems backwards.  Breaking large functions into smaller
functions is a good way to make code easier to understand.  By their
nature switch() statements tend to be large (in terms of lines of
code) so putting the switch() inside a separate function is likely to
be a good thing, not a bad thing.  The motivation for doing that is
not about working around a language limitation, but about writing
better code.
Re: Taming The Switch-Statement
#448
Author: Dan Cross
Date: Fri, 16 Oct 2026 12:40
79 lines
4176 bytes
In article <11arjmc$2qid7$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>...
>My syntax has cleaner and simpler syntax compared to C,...

I'm sure you meant to say, "my language has...".

>But it seems people don't value cleaner, more productive syntax when it 
>it comes to 'serious' languages, only scripting ones....
>
>[snip]
>>You know, I could well be right about all those points. Maybe my 
>language that has been around for 45 years really is a sweeter, cleaner 
>'C' which has solved most of the latter's quirks.
>
>And maybe other people's responses to that is just sour grapes.
>
>However one of interests is PL design - specifically at this level - and 
>how C gets it so wrong, how people defend it so much, how it evolves so 
>glacially, how much fixing its shortcomings is offloaded to tools, is 
>fascinating.
>
>It would have been nice to have a more objective discussion about such 
>aspects, with people not afraid to be a LOT more critical of C and its 
>tools that they have been.
>
>But I guess this is the wrong forum for that.

I think objective discussions of C are appropriate for
comp.lang.c.  Your description is not objective.  For example,
you claim that "people don't value cleaner, more productive
syntax...".  But those are subjective criteria.  Has it truly
never occurred to you that many other people just don't consider
your syntax significantly cleaner, or more productive?

I'm sure your language is very nice.  I recall looking at it at
one point and thinking it was fine, though I saw nothing
particularly special about it that would motivate me to want to
give up the considerable network advantages of using a more
common language.

You really think that's just sour grapes?  That everyone else is
just, what...mad at you because they feel the need to defend C's
honor or something?  C isn't a member of my family.  You're not
insulting my ancestry by pointing out flaws in it.  I'm not
going to get personally upset about its imperfections.

Perhaps people dismiss what you say because, despite your
self-aggrandizing words, you've shown that you don't actually
know C very well, and that you either do not care about, or
misunderstand, basic aspects of the language.  By your own
admission you ignore in the standards documents.  It is hard to
take the criticism of someone who doesn't understand what they
are criticizing very seriously, and subjectivity aside, relative
statements about the superiority of your language with respect
to a language you yourself don't know very well are similarly
difficult to take seriously.

> > Bart:  "Dennis Ritchie was a fool.  A fool, I say!  Haha!> 
>Ahahaha! Muwhahaha!"
>
>Simplest kind of function pointer:
>
> [snip; don't care]
>
>(Apparently it would be this, according to a tool which transpiles to C:
>
>             void (*one[10])(void), (*two[10])(void);

Yes, that's right.

>Fucking hell. Actually I didn't call DMR a fool. I did mention a 
>'numskull' which I now withdraw; I prefer to criticise ideas not people. 
>But this is a disaster.)

For someone who claims to want to discuss C objectively, you
sure do make a lot of subjective statements.

	- Dan C.
Re: Taming The Switch-Statement
#450
Author: Waldek Hebisch
Date: Fri, 16 Oct 2026 15:24
23 lines
2426 bytes
Lawrence D’Oliveiro <ldo@nz.invalid> wrote:
> On Tue, 13 Oct 2026 07:23:40 -0000 (UTC), 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'.
> 
> My experience in my own C code is quite the opposite. Lots of loops
> have exits in the middle, leading me to use forms like “for (;;)”. I
> also try to avoid putting “return” anywhere other than the end of a
> function, to make it easier to see the flow of control.

Well, usually there is a lot of loops.  Those with exit in the
middle are still significant.

Concernig 'return', having it in place where all work inside function
is done help me to see flow control and avoids complications.  In
case of search functions it means return from the middle of the loop.
IMO possible alternatives like flag variables or break and retrun
after loop are worse.

-- 
                              Waldek Hebisch
Re: Taming The Switch-Statement
#455
Author: Tim Rentsch
Date: Fri, 16 Oct 2026 21:22
17 lines
2342 bytes
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> I find "break NAME;", where "NAME" is the name of an enclosing
> construct, unambiguously better than "break N;", where N is the
> number of levels to break out of. [...]

Definitely.

> There's a proposal for C2y to use goto labels as loop names, and a
> competing one to define a new syntax like "for NAME (;;)" :
>
> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3377.pdf

I'm not particularly a fan of multi-level break/continue.  But if
we're going to have one of these, the second ("for NAME (;;)") is
unquestionably better.
Re: Taming The Switch-Statement
#456
Author: Lawrence D’Oliveiro
Date: Fri, 16 Oct 2026 21:42
13 lines
2434 bytes
On Fri, 16 Oct 2026 15:24:01 -0000 (UTC), Waldek Hebisch wrote:

> Concernig 'return', having it in place where all work inside
> function is done help me to see flow control and avoids
> complications. In case of search functions it means return from the
> middle of the loop. IMO possible alternatives like flag variables or
> break and retrun after loop are worse.

Code tends to do a lot of dynamic resource allocation these days, and
that requires cleanup. Doing a direct “return” from the middle of a
function body doesn’t allow for that.

Unless you use a GCC extension like “defer”, I suppose.
Re: Taming The Switch-Statement
#457
Author: Scott Lurndal
Date: Fri, 16 Oct 2026 21:46
33 lines
2539 bytes
Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> writes:
>On Fri, 16 Oct 2026 15:24:01 -0000 (UTC), Waldek Hebisch wrote:
>
>> Concernig 'return', having it in place where all work inside
>> function is done help me to see flow control and avoids
>> complications. In case of search functions it means return from the
>> middle of the loop. IMO possible alternatives like flag variables or
>> break and retrun after loop are worse.
>
>Code tends to do a lot of dynamic resource allocation these days, and
>that requires cleanup. Doing a direct “return” from the middle of a
>function body doesn’t allow for that.
>
>Unless you use a GCC extension like “defer”, I suppose.

Better to use the cleanup attribute (or RAII in C++).

#define RAII_CHM __attribute__((cleanup(auto_free_ptr)))
#define RAII_FILE __attribute__((cleanup(auto_close_file)))

int main(void) {
    // Memory and file handles are bound to this block scope
    RAII_CHM char *buffer = malloc(100);
    RAII_FILE FILE *fp = fopen("example.txt", "w");

    if (!buffer || !fp) {
        return -1; // Even on early exit, validly opened resources are cleaned up!
    }

    fprintf(fp, "Hello, RAII in C!");
    
    return 0; // Both buffer and fp are automatically freed/closed here
}
Re: Taming The Switch-Statement
#458
Author: Keith Thompson
Date: Fri, 16 Oct 2026 22:00
40 lines
3359 bytes
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> I find "break NAME;", where "NAME" is the name of an enclosing
>> construct, unambiguously better than "break N;", where N is the
>> number of levels to break out of. [...]
>
> Definitely.
>
>> There's a proposal for C2y to use goto labels as loop names, and a
>> competing one to define a new syntax like "for NAME (;;)" :
>>
>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3377.pdf
>
> I'm not particularly a fan of multi-level break/continue.  But if
> we're going to have one of these, the second ("for NAME (;;)") is
> unquestionably better.

Unquestionably?  Why?

I do like the fact that it doesn't conflate goto labels with loop
names, but I still prefer the "NAME: for (;;)" form, partly because
it's consistent with several other languages.

One minor drawback, IMHO, is that the name is easier to miss, because
it's not at the beginning of the line.  This is based on zero experience
using it.

(The same problem exists with function names.  Personally, I just
tolerate that rather than using the common convention of splitting the
return type and function name across two lines.  I think I would have
preferred a syntax that puts the function name first, but I wouldn't
suggest changing it.  I mildly dislike the convention of writing
    int
    func(void)
for reasons that are vague enough that I won't go into them.)

-- 
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
#459
Author: Keith Thompson
Date: Fri, 16 Oct 2026 22:03
12 lines
2152 bytes
Lawrence D’Oliveiro <ldo@nz.invalid> writes:
[...]
> Unless you use a GCC extension like “defer”, I suppose.

There is a proposal to add "defer" (or rather "_Defer") to C,
though it doesn't appear in the latest C2y draft.

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3928.pdf

-- 
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
#461
Author: bart
Date: Fri, 16 Oct 2026 23:01
59 lines
3625 bytes
On 16/10/2026 13:40, Dan Cross wrote:
> In article <11arjmc$2qid7$1@dont-email.me>, bart  <bc@freeuk.com> wrote:

>  Has it truly
> never occurred to you that many other people just don't consider
> your syntax significantly cleaner, or more productive?
So why is this style of syntax popular within scripting languages? (Lua, 
Julia, Ruby...)

Those are considered more productive.

> Perhaps people dismiss what you say because, despite your
> self-aggrandizing words, you've shown that you don't actually
> know C very well,

See the type syntax example below. How well do you need to know a 
language to see that that is just effing crazy? This is supposed to be a 
HLL, not a puzzle that needs to be solved or decoded via algorithms or 
employing tools!

> For someone who claims to want to discuss C objectively, you
> sure do make a lot of subjective statements.

Concerning type declaration syntax, lots of people including the C 
creators agree that it was misguided.

If lots of people agree, is that still being subjective? This is the 
example I think used in K&R:

  char *(*(**foo [][8])())[];

Most would consider this gobbledygook even if you know the rules. It is 
atrocious syntax. And what's 'foo' doing in the middle of it!

I think being defensive about it is being subjective, as you demonstrate 
here:

 >> [snip; don't care]

That is pretty much the attitude here in a nutshell.

What's often stated also is how successful C has been, but that doesn't 
magically make the syntax wonderful.

If DMR had instead produced a language that looked like mine (say like 
one of the Algols), and I came along in 2026 and proposed a syntax that 
looked like the above, what do you think the response would be?

I would rightly be laughed out of the forum.

So being 'objective' means disregarding history and widespread adoption. 
The latter doesn't make the language better, just more tolerated, with 
more effort put into tools to make it practical to use (with a nice 
sideline in teaching all its ins and outs).

Anyway, to me, pretty much the whole of C looked as badly and crudely 
put together as that, when I first came across it in 1982. My background 
had been with quite different languages.
Re: Taming The Switch-Statement
#462
Author: Janis Papanagnou
Date: Fri, 16 Oct 2026 23:29
63 lines
4497 bytes
On 2026-10-17 00:00, Keith Thompson wrote:
> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>[...]
>>> There's a proposal for C2y to use goto labels as loop names, and a
>>> competing one to define a new syntax like "for NAME (;;)" :
>>> [...]
>>
>> I'm not particularly a fan of multi-level break/continue.  But if
>> we're going to have one of these, the second ("for NAME (;;)") is
>> unquestionably better.
> 
> Unquestionably?  Why?

Why would one question an opinion? ;-)

> 
> I do like the fact that it doesn't conflate goto labels with loop
> names, but I still prefer the "NAME: for (;;)" form, partly because
> it's consistent with several other languages.

I've no strong opinion on that, but I find the "for NAME (;;)" to
clearer express the _local scope_ of embedded breaks or continues.
(Just a matter of taste, and my appreciation for locality.)

> 
> One minor drawback, IMHO, is that the name is easier to miss, because
> it's not at the beginning of the line.  This is based on zero experience
> using it.

If that sort of jump would be _restricted_ to the respective loop
then I'd not see how I'd miss that since it's closely placed. (It
might also help if, as shown above, some all-caps convention would
be applied to labels.)

> 
> (The same problem exists with function names.  Personally, I just
> tolerate that rather than using the common convention of splitting the
> return type and function name across two lines.  I think I would have
> preferred a syntax that puts the function name first, but I wouldn't
> suggest changing it.  I mildly dislike the convention of writing
>      int
>      func(void)
> for reasons that are vague enough that I won't go into them.)

Well, there were both variants, the Algol 60 "integer procedure"
and the Algol 68 "(...) INT :" (or Pascal's syntax equivalent with
a 'function' keyword, similarly, but with another syntax, in Awk).
But there's more syntactic factors that influence where the name is
located, so many variants are existing. (But we're anyway talking
just about "C", so it's all void, whatever personal preferences.)

The point with the separation of two lines is a question distinct
from the choice, unless we'd choose a syntactic variant of the two
forms, specifically "fname (parms) res_t" (i.e. without keyword).

As far as I recall, in "C", the name of the function was often put
separately (first in the line) to have an easy method to find its
declaration by simple "grep ^fname". (With any sophisticated editor
this might be a weak argument, though.)

Janis
Re: Taming The Switch-Statement
#463
Author: Keith Thompson
Date: Fri, 16 Oct 2026 23:53
14 lines
1694 bytes
bart <bc@freeuk.com> writes:
[...]
> What's often stated also is how successful C has been, but that
> doesn't magically make the syntax wonderful.

NOBODY THINKS C'S SYNTAX IS WONDERFUL.

We surrender.  You win.  Stop fighting.

[...]

-- 
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
#465
Author: Dan Cross
Date: Sat, 17 Oct 2026 03:19
120 lines
5646 bytes
In article <11auad0$3no1k$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>On 16/10/2026 13:40, Dan Cross wrote:
>> In article <11arjmc$2qid7$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>
>>  Has it truly
>> never occurred to you that many other people just don't consider
>> your syntax significantly cleaner, or more productive?
>
>So why is this style of syntax popular within scripting languages? (Lua, 
>Julia, Ruby...)
>
>Those are considered more productive.

...and you think that's because of the syntax, and not the high
level nature of those languages?

Wow.

>> Perhaps people dismiss what you say because, despite your
>> self-aggrandizing words, you've shown that you don't actually
>> know C very well,
>
>See the type syntax example below. How well do you need to know a 
>language to see that that is just effing crazy? This is supposed to be a 
>HLL, not a puzzle that needs to be solved or decoded via algorithms or 
>employing tools!

Yes, the syntax is pretty gnarly; Dennis Ritchie even said as
much.  Fixed in Go and Rust, but also, I doubt you've ever in
your life had a variable of type array of array of length 8 of
a pointer to a pointer to a function returning an array of
pointers to char.  Finding the most ridiculous example you can
is not really evidence of anything besides your weird obsession
with finding abstruse corner cases and holding them up as
reasons to dislike C.

>> For someone who claims to want to discuss C objectively, you
>> sure do make a lot of subjective statements.
>
>Concerning type declaration syntax, lots of people including the C 
>creators agree that it was misguided.

Yup.  But stupid examples are just stupid.

>If lots of people agree, is that still being subjective? This is the 
>example I think used in K&R:
>
>  char *(*(**foo [][8])())[];
>
>Most would consider this gobbledygook even if you know the rules. It is 
>atrocious syntax. And what's 'foo' doing in the middle of it!

Yup.  That's awful.

>I think being defensive about it is being subjective, as you demonstrate 
>here:
>
> >> [snip; don't care]

I fail to see how me not caring about your silly examples is
being defensive about C.  It says nothing about what I think
about C one way or the other; it only says I think your
arguments are poorly grounded.

>That is pretty much the attitude here in a nutshell.
>
>What's often stated also is how successful C has been, but that doesn't 
>magically make the syntax wonderful.

No one is claiming that C's popularity implies it's a "good"
language, however you'd like to define that.  There are useful
properties that come with using it, including a large ecosystem
of libraries and tools, huge number of programmers who know it,
lots of high-quality references, and so on.  But again, that
doesn't mean that C is good, just that we can leverage it's
popularity _usefully_.

>If DMR had instead produced a language that looked like mine (say like 
>one of the Algols), and I came along in 2026 and proposed a syntax that 
>looked like the above, what do you think the response would be?

But he didn't, and you didn't, so this is a meaningless
historical, "what if?"

>I would rightly be laughed out of the forum.

Bruh...I hate to break it to you, but....

>So being 'objective' means disregarding history and widespread adoption. 

Well, no...both of those are factors in choosing a language or
not.  We can discuss the semantics of the language, it's syntax,
etc; but we can also discuss tooling, engineering resources
availability (can you find programmers who know C?  More like,
can you find programmers who _don't_ know C, amirite?), library
and platform support, and so on.

>The latter doesn't make the language better, just more tolerated, with 
>more effort put into tools to make it practical to use (with a nice 
>sideline in teaching all its ins and outs).

This I can almost get behind, but you miss the forest for the
trees.  All those resources?  They exist; we can leverage them.
For BartLang?  Not so much.

Is C a good language?  Meh, it's not the worst, but far from the
best I've seen.  Was it a bad language in 1972, when it was
targeting a PDP-11/20?  No, it was pretty decent for that era.
Did it do all the stuff that fancy languages with advanced
compilers that ran on big machines could do?  No.  Did it need
to?  Also no.

>Anyway, to me, pretty much the whole of C looked as badly and crudely 
>put together as that, when I first came across it in 1982. My background 
>had been with quite different languages.

Yup.  Good for you.  So why do you keep posting here?

	- Dan C.
Re: Taming The Switch-Statement
#466
Author: Kenny McCormack
Date: Sat, 17 Oct 2026 11:09
47 lines
3010 bytes
In article <11audde$3oci5$1@kst.eternal-september.org>,
Keith Thompson  <Keith.S.Thompson+u@gmail.com> wrote:
>bart <bc@freeuk.com> writes:
>[...]
>> What's often stated also is how successful C has been, but that
>> doesn't magically make the syntax wonderful.
>
>NOBODY THINKS C'S SYNTAX IS WONDERFUL.

The funny thing is: I actually do.

I may be the only person here who actually thinks the syntax of C's
"switch" statement is just fine.  Once you realize that it *is* more of a
computed goto rather than a high level alternation construct like you'd
find in a real high level language (C is *not* a high level language; it is
properly referred to as a "mid level" language).

Note that the underlying issue here is easily dealt with if you do both of
the following:
    a) Enable the warning in your compiler that warns about (unannotated)
    fallthrough.
and
    b) Always put a comment when you intentionally do fallthrough.

This issue is kind of similar to the old:

    if (a = b) ...

thing - which really was a problem - right up until compilers started
warning about it.  Now that all compilers warn if you do that, it is no
longer a live issue, but people still bring it up occasionally.

FWIW, to take another popular whipping boy of C, I also actually like the
variable declaration syntax - which many people like to criticize as
"backwards" or "inside out".  Once you get used to it, it makes perfect
sense (to me, anyway).  I have no problem with a declaration like:

    int i,j,*ip,arr[10],foo(int bar);

Some would say that declares lots of different types of objects, but I
think of them all as ints (which is what the declaration is telling us).

-- 
The randomly chosen signature file that would have appeared here is more than 4-ish
lines long.  As such, it violates one or more Usenet RFCs.  In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
	http://user.xmission.com/~gazelle/Sigs/Seneca
Re: Taming The Switch-Statement
#467
Author: bart
Date: Sat, 17 Oct 2026 11:34
105 lines
5766 bytes
On 17/10/2026 04:19, Dan Cross wrote:
> In article <11auad0$3no1k$1@dont-email.me>, bart  <bc@freeuk.com> wrote:

>> Those are considered more productive.
> 
> ...and you think that's because of the syntax, and not the high
> level nature of those languages?

It's a combination.

> Yes, the syntax is pretty gnarly; Dennis Ritchie even said as
> much.  Fixed in Go and Rust, but also, I doubt you've ever in
> your life had a variable of type array of array of length 8 of
> a pointer to a pointer to a function returning an array of
> pointers to char.  Finding the most ridiculous example you can
> is not really evidence of anything besides your weird obsession

That was the first one I saw online next to a quote from K&R and I 
assumed it was from the book. In fact the example from the book is this:

   char (*(*x())[])()

I've no idea what the means either. The point is not that the examples 
are ridiculous, but that they are hard to convert to and from LTR form 
which is how we think. With LTR syntax it becomes utterly trivial to 
read or write them, no matter how complex.

(There's a tool called CDECL that translates types from C syntax to LTR 
English or vice versa. It calls the C versions 'gibberish'. This is a 
real thing!)


> with finding abstruse corner cases and holding them up as
> reasons to dislike C.

The first example I gave was the simplest form of function pointer, 
where the syntax is 'void(*)(void)'. Hardly a corner case, and it 
rapidly goes downhill.

If meeting C for the first time, that does not bode well. If the 
designers did not care about this, that does not inspire confidence in 
the rest of the language.

>> If DMR had instead produced a language that looked like mine (say like
>> one of the Algols), and I came along in 2026 and proposed a syntax that
>> looked like the above, what do you think the response would be?
> 
> But he didn't, and you didn't, so this is a meaningless
> historical, "what if?"

You don't get the point. If C had used LTR type syntax and somebody 
proposed using inside-out back-and-forth syntax like 'void(*)(void)', 
they'd think they were having a laugh, as it would be ridiculous.

But this is exactly what I think about it anyway, no matter that 100 
million programs have battled with it for 50 years.

> 
>> So being 'objective' means disregarding history and widespread adoption.
> 
> Well, no...both of those are factors in choosing a language or
> not.  We can discuss the semantics of the language, it's syntax,
> etc; but we can also discuss tooling, engineering resources
> availability (can you find programmers who know C?  More like,
> can you find programmers who _don't_ know C, amirite?), library
> and platform support, and so on.

Yes, this is my point; it is tolerated, and people learn to work with 
it. But how much extra effort has been expended, compared if they'd 
tried a bit harder to get a better language at the start? Or even during 
its first decade.

> Is C a good language?  Meh, it's not the worst, but far from the
> best I've seen.  Was it a bad language in 1972, when it was
> targeting a PDP-11/20?  No, it was pretty decent for that era.

Disagree.

> Did it do all the stuff that fancy languages with advanced
> compilers that ran on big machines could do?  No.  Did it need
> to?  Also no.

I think C was first created for PDP7 with 4K words, then moved to PDP11 
(don't know the spec).

My first language was created nearly a decade later on a /homemade/ 
microprocessor system with 32KB, but no viable storage. So compiler 
binary and data, editor, program source code, binary and data all had to 
reside in memory at the same time.

That crude language had 'print x' and loops that looked like 'for i:=a 
to b do'. It also had a 'byte' type (ie. u8).

A year or two later, with 64KB and storage, it was more full-featured. 
It was a viable and practical alternative to C which I had looked at, 
and dismissed.

Fun fact: my copy of K&R1 cost me ÂŁ12. My first Z80 processor cost ÂŁ10.

My point is you can't excuse C being what it is due to hardware limitations.

I used PDP11 quite a bit (/34) and that had a decent Fortran implementation.

My own stuff was done in my spare time for no extra pay, on 8-bit 
machines I helped develop for my company, without the backing of Bell Labs.
Re: Taming The Switch-Statement
#468
Author: bart
Date: Sat, 17 Oct 2026 12:11
55 lines
3247 bytes
On 17/10/2026 12:09, Kenny McCormack wrote:
> In article <11audde$3oci5$1@kst.eternal-september.org>,
> Keith Thompson  <Keith.S.Thompson+u@gmail.com> wrote:
>> bart <bc@freeuk.com> writes:
>> [...]
>>> What's often stated also is how successful C has been, but that
>>> doesn't magically make the syntax wonderful.
>>
>> NOBODY THINKS C'S SYNTAX IS WONDERFUL.
> 
> The funny thing is: I actually do.
> 
> I may be the only person here who actually thinks the syntax of C's
> "switch" statement is just fine.  Once you realize that it *is* more of a
> computed goto

Then maybe the syntax for it should have been:

    goto (x) {}

instead of:

    switch (x) {}

That would not clash with 'goto label', nor the 'goto *(x)' of gnu C.

It would make it clearer that this is a cruder construct than 'switch' 
pretends to be, AND it saves a keyword!

That saving could have gone towards giving switch-break its own keyword 
instead of having to share 'break' with loops (because there was 
apparently a shortage of keywords in 1972).

That was always going to clash at some point, and it does.

> sense (to me, anyway).  I have no problem with a declaration like:
> 
>      int i,j,*ip,arr[10],foo(int bar);
> 
> Some would say that declares lots of different types of objects, but I
> think of them all as ints (which is what the declaration is telling us).

It's taking a bunch of unrelated types of arbitrary complexity, but 
because they all end with a type T when expressed in LTR form, they all 
belong together?

That doesn't work: i, ip, arr, foo all have different types.

They only have the same types when fully dereferenced, indexed or 
called, when written as i, *ip, arr[i], foo(i). This is NOT when happens 
within the declaration, and it might not happen when they appear in 
expressions either.

It's just confusing.
Re: Taming The Switch-Statement
#469
Author: Janis Papanagnou
Date: Sat, 17 Oct 2026 13:15
61 lines
3837 bytes
On 2026-10-17 13:09, Kenny McCormack wrote:
> In article <11audde$3oci5$1@kst.eternal-september.org>,
> Keith Thompson  <Keith.S.Thompson+u@gmail.com> wrote:
>> bart <bc@freeuk.com> writes:
>> [...]
>>> What's often stated also is how successful C has been, but that
>>> doesn't magically make the syntax wonderful.
>>
>> NOBODY THINKS C'S SYNTAX IS WONDERFUL.
> 
> The funny thing is: I actually do.

Hah! - That's the touche when someone formulates generalizing
statements about "all people" or about "nobody". :-)

That said; I'd anyway never expected anyone to have chosen the
attribute "wonderful", though (which was the word used here).

But I also think that what Keith wanted to say was that "nobody
has *said* - before your post - that C's syntax is wonderful"
(in reply to bart's typical wrong imputations and hallucinations
what others would have implied by some [unrelated] statement).

> ['switch' topic - snipped]
> ["if (a = b)" topic - snipped]
> 
> FWIW, to take another popular whipping boy of C, I also actually like the
> variable declaration syntax -

(I'm reading that as "declaration syntax", i.e. without "variable".)

> which many people like to criticize as
> "backwards" or "inside out".  Once you get used to it, it makes perfect
> sense (to me, anyway).  [...]

But isn't that exactly the point, that you need to "get used"
to something, which makes it appear as a "bad" design decision
to others. (I certainly got used to many things in life, but
some I then just try to avoid.)

And of course "it makes sense"; if you can formally describe it -
and programming language syntaxes have that property - it makes
sense. Is it a "good" (or even a "wonderful") design? - I don't
think so. YMMV.

I like some of the programming-idioms that "C" made popular, but
its syntax - and specifically that convoluted declaration syntax -
is certainly not amongst them. (Or requiring 'typedef' workarounds
to make some of the less-trivial declarations manageable and the
code significantly better readable.)

We can observe that if one spent a lot time in some context, and
is used to it, and at some point even masters it, he might not be
considering it as negative as someone who is more of a wanderer
between worlds, for whom the advantages and disadvantages of the
worlds might be more obvious. - And all those hypes...

Oh! - I just noticed I'm digressing.

Janis
Re: Taming The Switch-Statement
#471
Author: Tim Rentsch
Date: Sat, 17 Oct 2026 15:34
19 lines
1994 bytes
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> bart <bc@freeuk.com> writes:
> [...]
>
>> What's often stated also is how successful C has been, but that
>> doesn't magically make the syntax wonderful.
>
> NOBODY THINKS C'S SYNTAX IS WONDERFUL.
>
> We surrender.  You win.  Stop fighting.

If you would stop trying to engage with bart you wouldn't
get so frustrated.  And everyone would be happier.  (It
would be even nicer if other people would follow this
advice too... hint hint hint).

Incidentally I don't think C's declaration is wonderful,
but I don't mind it either.
Re: Taming The Switch-Statement
#472
Author: Michael S
Date: Sat, 17 Oct 2026 16:39
41 lines
3530 bytes
On Fri, 16 Oct 2026 15:00:27 -0700
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> > Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:  
> >> I find "break NAME;", where "NAME" is the name of an enclosing
> >> construct, unambiguously better than "break N;", where N is the
> >> number of levels to break out of. [...]  
> >
> > Definitely.
> >  
> >> There's a proposal for C2y to use goto labels as loop names, and a
> >> competing one to define a new syntax like "for NAME (;;)" :
> >>
> >> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
> >> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3377.pdf  
> >
> > I'm not particularly a fan of multi-level break/continue.  But if
> > we're going to have one of these, the second ("for NAME (;;)") is
> > unquestionably better.  
> 
> Unquestionably?  Why?
> 

I don't know why Tim prefers it.
I prefer it (strongly) because it is different from regular label. So
reader that wants to understand a flow of the program should not be
concerned with possibility of jumping to it from places outside for().

> I do like the fact that it doesn't conflate goto labels with loop
> names, but I still prefer the "NAME: for (;;)" form, partly because
> it's consistent with several other languages.
>

You mentioned itself that in Ada loop labels are distinct from regular
labels. I would think that Ada alone easily outweighs "several other
languages" if we compare by number (and likely by quality) of man-hours
invested into thinking and discussion of syntactic features.
Anyway I value appeal to success more than appeal to authority so by my
own standards the argument above is weak.
Re: Taming The Switch-Statement
#473
Author: bart
Date: Sat, 17 Oct 2026 17:23
60 lines
4228 bytes
On 17/10/2026 17:39, Michael S wrote:
> On Fri, 16 Oct 2026 15:00:27 -0700
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> 
>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>> I find "break NAME;", where "NAME" is the name of an enclosing
>>>> construct, unambiguously better than "break N;", where N is the
>>>> number of levels to break out of. [...]
>>>
>>> Definitely.
>>>   
>>>> There's a proposal for C2y to use goto labels as loop names, and a
>>>> competing one to define a new syntax like "for NAME (;;)" :
>>>>
>>>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
>>>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3377.pdf
>>>
>>> I'm not particularly a fan of multi-level break/continue.  But if
>>> we're going to have one of these, the second ("for NAME (;;)") is
>>> unquestionably better.
>>
>> Unquestionably?  Why?
>>
> 
> I don't know why Tim prefers it.
> I prefer it (strongly) because it is different from regular label. So
> reader that wants to understand a flow of the program should not be
> concerned with possibility of jumping to it from places outside for().
> 
>> I do like the fact that it doesn't conflate goto labels with loop
>> names, but I still prefer the "NAME: for (;;)" form, partly because
>> it's consistent with several other languages.
>>
> 
> You mentioned itself that in Ada loop labels are distinct from regular
> labels. I would think that Ada alone easily outweighs "several other
> languages" if we compare by number (and likely by quality) of man-hours
> invested into thinking and discussion of syntactic features.
> Anyway I value appeal to success more than appeal to authority so by my
> own standards the argument above is weak.

I was around when Ada was being developed and refined, a process that 
took years.

By contrast, C looks like it was just thrown together with little 
thought, and probably that is exactly what happened.

In the end, Ada was a language that you could admire, but you'd rather 
other people used. It's a solid language but I found it too formal and 
rather dull (not that it was available for me to use).

Still, I borrowed some syntactic features from it.

One interesting fact that people might forget is that it was 
case-insensitive, a welcome difference IMV.



Re: Taming The Switch-Statement
#474
Author: Tim Rentsch
Date: Sat, 17 Oct 2026 17:30
33 lines
3175 bytes
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>
>>> I find "break NAME;", where "NAME" is the name of an enclosing
>>> construct, unambiguously better than "break N;", where N is the
>>> number of levels to break out of.  [...]
>>
>> Definitely.
>>
>>> There's a proposal for C2y to use goto labels as loop names, and a
>>> competing one to define a new syntax like "for NAME (;;)" :
>>>
>>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
>>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3377.pdf
>>
>> I'm not particularly a fan of multi-level break/continue.  But if
>> we're going to have one of these, the second ("for NAME (;;)") is
>> unquestionably better.
>
> Unquestionably?  Why?

Before I respond I'd like to ask you to list as many potential
differentiators as you can think of, without regard to which of
the two suggestions each one benefits, and without saying which
ones you think favor one choice or the other.  If you do that I
can try to go through your list, say which ones I think are
significant, which of the two choices each one favors, and maybe
also assign some sort of priority ranking.  Also that would give
me a chance to think about whether there are other differentiators
not on your list but that could seem to me to be relevant.
Re: Taming The Switch-Statement
#475
Author: Dan Cross
Date: Sat, 17 Oct 2026 17:36
19 lines
1585 bytes
In article <11b0av3$edsd$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>[snip]
>I was around when Ada was being developed and refined, a process that 
>took years.
>
>By contrast, C looks like it was just thrown together with little 
>thought, and probably that is exactly what happened.
>[snip]

Oh put a sock in it, guy.

No one here slavishly worships C or thinks it is perfect, but
taking every little chance you can to throw barbs at it with
otherwise utterly information-free posts like this, is merely
noise.  Honestly, the constant "notice me, senpai!" posts are
just pathetic attention-seeking.

	- Dan C.
Re: Taming The Switch-Statement
#477
Author: Keith Thompson
Date: Sat, 17 Oct 2026 17:54
48 lines
3897 bytes
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>> I find "break NAME;", where "NAME" is the name of an enclosing
>>>> construct, unambiguously better than "break N;", where N is the
>>>> number of levels to break out of.  [...]
>>>
>>> Definitely.
>>>
>>>> There's a proposal for C2y to use goto labels as loop names, and a
>>>> competing one to define a new syntax like "for NAME (;;)" :
>>>>
>>>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
>>>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3377.pdf
>>>
>>> I'm not particularly a fan of multi-level break/continue.  But if
>>> we're going to have one of these, the second ("for NAME (;;)") is
>>> unquestionably better.
>>
>> Unquestionably?  Why?
>
> Before I respond I'd like to ask you to list as many potential
> differentiators as you can think of, without regard to which of
> the two suggestions each one benefits, and without saying which
> ones you think favor one choice or the other.  If you do that I
> can try to go through your list, say which ones I think are
> significant, which of the two choices each one favors, and maybe
> also assign some sort of priority ranking.  Also that would give
> me a chance to think about whether there are other differentiators
> not on your list but that could seem to me to be relevant.

No, Tim, I absolutely will not do that.

I asked you to explain two words that you wrote.  You do not get to
assign me homework as a precondition for answering a simple question.

You asserted that it's "unquestionably better".  You can support
that assertion or not.  If you're not going to answer my question,
an easier way to do that is to remain silent.  I'm used to that
from you.

To be blunt, I don't care enough about your opinion to do extra
work to extract it from 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
#478
Author: Dan Cross
Date: Sat, 17 Oct 2026 17:58
151 lines
7056 bytes
In article <11avmfb$55rt$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>On 17/10/2026 04:19, Dan Cross wrote:
>> In article <11auad0$3no1k$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>>> Those are considered more productive.
>> 
>> ...and you think that's because of the syntax, and not the high
>> level nature of those languages?
>
>It's a combination.

Riiiight.  C++ is widely considered "more productive" than C,
and yet shares most of the syntactic warts you complain about so
readily.

>> Yes, the syntax is pretty gnarly; Dennis Ritchie even said as
>> much.  Fixed in Go and Rust, but also, I doubt you've ever in
>> your life had a variable of type array of array of length 8 of
>> a pointer to a pointer to a function returning an array of
>> pointers to char.  Finding the most ridiculous example you can
>> is not really evidence of anything besides your weird obsession
>
>That was the first one I saw online next to a quote from K&R and I 
>assumed it was from the book. In fact the example from the book is this:
>
>   char (*(*x())[])()
>
>I've no idea what the means either. The point is not that the examples 
>are ridiculous, but that they are hard to convert to and from LTR form 
>which is how we think. With LTR syntax it becomes utterly trivial to 
>read or write them, no matter how complex.
>
>(There's a tool called CDECL that translates types from C syntax to LTR 
>English or vice versa. It calls the C versions 'gibberish'. This is a 
>real thing!)

Yes.  C's declaration syntax is famously abstruse; film at 11.

>> with finding abstruse corner cases and holding them up as
>> reasons to dislike C.
>
>The first example I gave was the simplest form of function pointer, 
>where the syntax is 'void(*)(void)'. Hardly a corner case, and it 
>rapidly goes downhill.

Ok.

>If meeting C for the first time, that does not bode well. If the 
>designers did not care about this, that does not inspire confidence in 
>the rest of the language.

Ok.

>>> If DMR had instead produced a language that looked like mine (say like
>>> one of the Algols), and I came along in 2026 and proposed a syntax that
>>> looked like the above, what do you think the response would be?
>> 
>> But he didn't, and you didn't, so this is a meaningless
>> historical, "what if?"
>
>You don't get the point.

There does not appear to be one.

>If C had used LTR type syntax and somebody 
>proposed using inside-out back-and-forth syntax like 'void(*)(void)', 
>they'd think they were having a laugh, as it would be ridiculous.

Unknowable.

>But this is exactly what I think about it anyway, no matter that 100 
>million programs have battled with it for 50 years.

Irrelevant.

>>> So being 'objective' means disregarding history and widespread adoption.
>> 
>> Well, no...both of those are factors in choosing a language or
>> not.  We can discuss the semantics of the language, it's syntax,
>> etc; but we can also discuss tooling, engineering resources
>> availability (can you find programmers who know C?  More like,
>> can you find programmers who _don't_ know C, amirite?), library
>> and platform support, and so on.
>
>Yes, this is my point; it is tolerated, and people learn to work with 
>it. But how much extra effort has been expended, compared if they'd 
>tried a bit harder to get a better language at the start? Or even during 
>its first decade.

Then your point is minor at best.  Here's a thought experiment:
suppose I suddenly came to my senses and agreed with everything
you say: I'm willing to totally toss out C and adopt Bart's
language yesterday.  Where do I get a compiler?  What learning
resources exist?  Oh, and I need it to generate code for an
ARM Cortex-M0 part; does it do that?  I also need RV64GC and
x86_64 and probably aarch64, too.  Might want to throw in
Xtensa while we're at it: does your compiler do all of that?
What if I need a debugger?  Oh, and I need to use crypto
libraries that are supplied from a vendor; they use the C ABI.
What's the inter-op story like?

>> Is C a good language?  Meh, it's not the worst, but far from the
>> best I've seen.  Was it a bad language in 1972, when it was
>> targeting a PDP-11/20?  No, it was pretty decent for that era.
>
>Disagree.

Really, the entire thread could be summed up in that one word,
and it would save everyone a lot of time.

>> Did it do all the stuff that fancy languages with advanced
>> compilers that ran on big machines could do?  No.  Did it need
>> to?  Also no.
>
>I think C was first created for PDP7 with 4K words, then moved to PDP11 
>(don't know the spec).

No.  That was B; the PDP-7 was an 18-bit word-oriented machine,
and was archaic even in 1968 when they started using it.  C was
done on the PDP-11.  An early cross-compilation environment on a
GE-635 computer also existed, but the primary work on the
language was on the 11/20 running Unix.

You know, all of this is in Dennis Ritchie's C history paper,
presented at SIGPLAN's HOPL-II, which is online.  If you could
get over yourself for like 20 minutes you could read it, and
then not talk out your ass about history.
https://www.nokia.com/bell-labs/about/dennis-m-ritchie/chist.html

I suspect your general factual resistance is one of the several
reasons so few people around here take you or your language
seriously.

>[snip]
>My point is you can't excuse C being what it is due to hardware limitations.
>
>I used PDP11 quite a bit (/34) and that had a decent Fortran implementation.

(A very different machine from an 11/20.)

>My own stuff was done in my spare time for no extra pay, on 8-bit 
>machines I helped develop for my company, without the backing of Bell Labs.

Good for you.  Totally irrelevant to the history of C.

Let me forestall the inevitable: you are going to reply and just
repeat the same things over again.  I don't care.  None of this
is an objective discussion of C; and it really comes across as
you just seeking affirmation, which is genuinely sad.

	- Dan C.
Re: Taming The Switch-Statement
#479
Author: Michael S
Date: Sat, 17 Oct 2026 18:03
77 lines
4952 bytes
On Sat, 17 Oct 2026 18:23:47 +0100
bart <bc@freeuk.com> wrote:

> On 17/10/2026 17:39, Michael S wrote:
> > On Fri, 16 Oct 2026 15:00:27 -0700
> > Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> >   
> >> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:  
> >>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:  
> >>>> I find "break NAME;", where "NAME" is the name of an enclosing
> >>>> construct, unambiguously better than "break N;", where N is the
> >>>> number of levels to break out of. [...]  
> >>>
> >>> Definitely.
> >>>     
> >>>> There's a proposal for C2y to use goto labels as loop names, and
> >>>> a competing one to define a new syntax like "for NAME (;;)" :
> >>>>
> >>>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
> >>>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3377.pdf  
> >>>
> >>> I'm not particularly a fan of multi-level break/continue.  But if
> >>> we're going to have one of these, the second ("for NAME (;;)") is
> >>> unquestionably better.  
> >>
> >> Unquestionably?  Why?
> >>  
> > 
> > I don't know why Tim prefers it.
> > I prefer it (strongly) because it is different from regular label.
> > So reader that wants to understand a flow of the program should not
> > be concerned with possibility of jumping to it from places outside
> > for(). 
> >> I do like the fact that it doesn't conflate goto labels with loop
> >> names, but I still prefer the "NAME: for (;;)" form, partly because
> >> it's consistent with several other languages.
> >>  
> > 
> > You mentioned itself that in Ada loop labels are distinct from
> > regular labels. I would think that Ada alone easily outweighs
> > "several other languages" if we compare by number (and likely by
> > quality) of man-hours invested into thinking and discussion of
> > syntactic features. Anyway I value appeal to success more than
> > appeal to authority so by my own standards the argument above is
> > weak.  
> 
> I was around when Ada was being developed and refined, a process that 
> took years.
> 
> By contrast, C looks like it was just thrown together with little 
> thought, and probably that is exactly what happened.
> 
> In the end, Ada was a language that you could admire, but you'd
> rather other people used. It's a solid language but I found it too
> formal and rather dull (not that it was available for me to use).
> 

I use Ada off-spring VHDL very regularly.
I prefer it over Verilog, but I do it due to semantics and mostly
despite [inherited from Ada] syntax.

> Still, I borrowed some syntactic features from it.
> 
> One interesting fact that people might forget is that it was 
> case-insensitive, a welcome difference IMV.
>

I don't like case-insensitivity, except, may be, for keywords.
I don't like begin..end.
Most of all, I don't like nested procedures that have visibility of
local variables of the parent (That's related to Ada, not significant
in context of VHDL).
I suppose, I don't like most of the thing that you like about
programming languages.


Re: Taming The Switch-Statement
#480
Author: bart
Date: Sat, 17 Oct 2026 20:40
88 lines
4933 bytes
On 17/10/2026 18:58, Dan Cross wrote:
> In article <11avmfb$55rt$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>> On 17/10/2026 04:19, Dan Cross wrote:
>>> In article <11auad0$3no1k$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>>>> Those are considered more productive.
>>>
>>> ...and you think that's because of the syntax, and not the high
>>> level nature of those languages?
>>
>> It's a combination.
> 
> Riiiight.

So greatly simplifying syntax, all other things being equal, does not 
increase productivity at all? Gotcha.

> Yes.  C's declaration syntax is famously abstruse; film at 11.

And ... that's it? Just accept it? How about doing something about it!

I'm angry because to me C was so unusable that I had to create and 
maintain my own products over decades.

Then I later found that C had insinuated itself into every API and every 
open source product I wanted to use. Even ABIs, supposedly 
language-neutral, pay deference to it. Even as a compiler target, there 
was no other choice.

So I ended having to deal with it anyway, but thankfully avoided have to 
write it.


>> If C had used LTR type syntax and somebody
>> proposed using inside-out back-and-forth syntax like 'void(*)(void)',
>> they'd think they were having a laugh, as it would be ridiculous.
> 
> Unknowable.

You do know; you just don't want to admit it. (Imagine introducing C 
declarations into a current language.)

> Then your point is minor at best.  Here's a thought experiment:
> suppose I suddenly came to my senses and agreed with everything
> you say: I'm willing to totally toss out C and adopt Bart's
> language yesterday.

THIS IS NOT ABOUT MY LANGUAGE!

Why hasn't there long been an alternative systems language that didn't 
have C's crazy syntax and stupid quirks? I mean like 30-50 years ago.

Yes, mine has lots of examples of how some alternative features could 
work; so what? I am not selling my language.


>  Where do I get a compiler?  What learning
> resources exist?  Oh, and I need it to generate code for an
> ARM Cortex-M0 part; does it do that?  I also need RV64GC and
> x86_64 and probably aarch64, too.  Might want to throw in
> Xtensa while we're at it: does your compiler do all of that?
> What if I need a debugger?  Oh, and I need to use crypto
> libraries that are supplied from a vendor; they use the C ABI.
> What's the inter-op story like?

My language was for in-house use; it was never intended as a product.

(If you really want to try it, I can supply an ASM file for you to 
build, but it works on Windows. I can no longer supply a transpiled C 
version that part work on Linux; I have destroyed my C-related projects.)

The C API (not ABI) point is valid, and another bugbear. Why can't APIs 
be expressed in a language-agnostic manner? This would help other 
languages that also need to solve the problem of creating bindings to 
libraries that primarily use a C API.

C is a terrible choice for a cross-language API, as too many C-isms 
creep in (like C macros, or vaguely defined types, including the famous 
'plain char' that exists in no other language, which is neither signed 
nor unsigned, and above all C preprocessor features).

> Good for you.  Totally irrelevant to the history of C.

It means that meagre hardware resources don't have to compromise the 
design of a language, especially when it comes to syntax.

So you can't use limited resources as an excuse for its questionable 
choices. Actually some choices actually made it harder to parse.
Re: Taming The Switch-Statement
#482
Author: Tim Rentsch
Date: Sun, 18 Oct 2026 02:25
65 lines
4781 bytes
antispam@fricas.org (Waldek Hebisch) writes:

> Lawrence D?Oliveiro <ldo@nz.invalid> wrote:
>
>> On Tue, 13 Oct 2026 07:23:40 -0000 (UTC), 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'.
>>
>> My experience in my own C code is quite the opposite.  Lots of loops
>> have exits in the middle, leading me to use forms like ?for (;;)?. I
>> also try to avoid putting ?return?  anywhere other than the end of a
>> function, to make it easier to see the flow of control.
>
> Well, usually there is a lot of loops.  Those with exit in the
> middle are still significant.
>
> Concernig 'return', having it in place where all work inside function
> is done help me to see flow control and avoids complications.  In
> case of search functions it means return from the middle of the loop.
> IMO possible alternatives like flag variables or break and retrun
> after loop are worse.

I rarely use 'break' to exit a loop.  Part of this is that I try to
write standard loops so that they complete as part of the loop test
(i.e., in while() or for() control expressions).  That isn't the
whole story though so let me talk about 'return'.

Most of the functions I write have exactly one return, at the end of
the function.  I estimate this pattern accounts for around 85% of
all functions, let's say plus or minus 5%.

Sometimes functions have early returns for errors or exceptional
conditions.  Early returns are easily seen to lie outside the main
body of function processing so they don't interfere with
understanding what the rest of the function is doing or how it
works.

A fairly common sub-pattern are functions most of whose body is a
switch() statement, with all of the switch() cases being a simple
return.

It does sometimes happen that a function will have a loop with a
return in the middle, and also a return at the end for what to do if
the loop terminates.  To me having an in-loop return looks better
than using an assignment and a break.

A fairly rare but important pattern is what I might call vectoring
or decomposition.  Here the function body serves to distinguish and
separate out different regimes of subprocessing.  To continue
processing in a particular regime, a return is used not to directly
yield a value but rather to call a further function to handle that
sub-domain.  The benefit here is both to keep function bodies small
and to allow re-use of commonly called sub-functions.

Two aspects are important for having these different styles work
together.  One is that it's easy to distinguish the different kinds
of patterns, and by far the most simple pattern is the most common.
The other is to be sure to keep function bodies small.  Keeping
function bodies small goes a long way in making them easy to
understand, which obviously is a key property in writing good code.
Also keeping function bodies small effectively prevents mixing
different styles in a single function, serving to reinforce point
one.
Re: Taming The Switch-Statement
#485
Author: David Brown
Date: Sun, 18 Oct 2026 10:38
63 lines
4160 bytes
On 16/10/2026 23:46, Scott Lurndal wrote:
> Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> writes:
>> On Fri, 16 Oct 2026 15:24:01 -0000 (UTC), Waldek Hebisch wrote:
>>
>>> Concernig 'return', having it in place where all work inside
>>> function is done help me to see flow control and avoids
>>> complications. In case of search functions it means return from the
>>> middle of the loop. IMO possible alternatives like flag variables or
>>> break and retrun after loop are worse.
>>
>> Code tends to do a lot of dynamic resource allocation these days, and
>> that requires cleanup. Doing a direct “return” from the middle of a
>> function body doesn’t allow for that.
>>
>> Unless you use a GCC extension like “defer”, I suppose.

"defer" is not a gcc extension.  You can "defer" macro, using gcc's 
"cleanup" attribute (which /is/ an extension) :

<https://gustedt.gitlabpages.inria.fr/defer/>

As I understand it, "defer" is in the proposal stage and could make it 
into C2y, but it is not yet in the draft standard.  There are test 
implementations in gcc, clang, and a couple of other compilers.

> 
> Better to use the cleanup attribute (or RAII in C++).
> 
> #define RAII_CHM __attribute__((cleanup(auto_free_ptr)))
> #define RAII_FILE __attribute__((cleanup(auto_close_file)))
> 
> int main(void) {
>      // Memory and file handles are bound to this block scope
>      RAII_CHM char *buffer = malloc(100);
>      RAII_FILE FILE *fp = fopen("example.txt", "w");
> 
>      if (!buffer || !fp) {
>          return -1; // Even on early exit, validly opened resources are cleaned up!
>      }
> 
>      fprintf(fp, "Hello, RAII in C!");
>      
>      return 0; // Both buffer and fp are automatically freed/closed here
> }

"defer" has a number of benefits over "cleanup", but "cleanup" has the 
advantage that it is available now on gcc and clang - if portability is 
not an issue.

Still, I would not write code like you show above - in C, people expect 
more explicit code, and you are hiding non-standard C behaviour with 
somewhat obscure names.  (Obscurity is, of course, dependent on how much 
you use the feature in your code.)

I'd rather have :

#define RAII(cleanup_func) __attribute__((cleanup(cleanup_func)))

	RAII(auto_free_ptr) char * buffer = malloc(100);
	RAII(auto_close_file) FILE * fp = fopen("example.txt", "w");


Re: Taming The Switch-Statement
#486
Author: David Brown
Date: Sun, 18 Oct 2026 10:48
61 lines
4244 bytes
On 17/10/2026 01:29, Janis Papanagnou wrote:
> On 2026-10-17 00:00, Keith Thompson wrote:
>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>> [...]
>>>> There's a proposal for C2y to use goto labels as loop names, and a
>>>> competing one to define a new syntax like "for NAME (;;)" :
>>>> [...]
>>>
>>> I'm not particularly a fan of multi-level break/continue.  But if
>>> we're going to have one of these, the second ("for NAME (;;)") is
>>> unquestionably better.
>>
>> Unquestionably?  Why?
> 
> Why would one question an opinion? ;-)

Time didn't word it as a personal opinion - he made it clear that he 
doesn't think anyone else could have a different opinion.

The C standards committee collectively reached an agreement counter to 
Tim's thoughts, so clearly his preferred variant is /not/ unquestionably 
better.

> 
>>
>> I do like the fact that it doesn't conflate goto labels with loop
>> names, but I still prefer the "NAME: for (;;)" form, partly because
>> it's consistent with several other languages.
> 
> I've no strong opinion on that, but I find the "for NAME (;;)" to
> clearer express the _local scope_ of embedded breaks or continues.
> (Just a matter of taste, and my appreciation for locality.)
> 

A main objection to "name: for ..." is that with function-scope labels, 
you need a new name for every labelled loop or switch.  That may be an 
inconvenience, especially for macro with labelled loops, or for 
copy-and-paste code.  There is a proposal to deal with that which 
basically says :

1. Any "break label;" or "continue label;" refers to the innermost 
containing loop or switch with that label.

2. Any "label" used in "goto label;" must be unique in the function.

Those rules give a simple and intuitive fix without affecting existing code.

Beyond that, "name: for ..." or "for name ..." is, as you say, mostly a 
matter of taste.  (There are proposals for both versions, and you can 
look them up to see the arguments.)

> 
> As far as I recall, in "C", the name of the function was often put
> separately (first in the line) to have an easy method to find its
> declaration by simple "grep ^fname". (With any sophisticated editor
> this might be a weak argument, though.)
> 

I think it was popularised with a shortcut in emacs.
Re: Taming The Switch-Statement
#487
Author: bart
Date: Sun, 18 Oct 2026 11:04
47 lines
3653 bytes
On 18/10/2026 11:48, David Brown wrote:
> On 17/10/2026 01:29, Janis Papanagnou wrote:

>> I've no strong opinion on that, but I find the "for NAME (;;)" to
>> clearer express the _local scope_ of embedded breaks or continues.
>> (Just a matter of taste, and my appreciation for locality.)
>>
> 
> A main objection to "name: for ..." is that with function-scope labels, 
> you need a new name for every labelled loop or switch.  That may be an 
> inconvenience, especially for macro with labelled loops, or for copy- 
> and-paste code.  There is a proposal to deal with that which basically 
> says :
> 
> 1. Any "break label;" or "continue label;" refers to the innermost 
> containing loop or switch with that label.
> 
> 2. Any "label" used in "goto label;" must be unique in the function.
> 
> Those rules give a simple and intuitive fix without affecting existing 
> code.


There's something missing. Labels usually live in their own, 
function-wide name space.

But if you have two loops like this:

    L1: while () {} L2:
    L1: while () {} L2:

Then even if no gotos exist to L1, is that rule somehow relaxed for 
those L1s to allow them to co-exist? (While still applying to non-loop 
labels L2, which would clash.)

Will the L1s still live within the regular name space? (Presumably each 
will now be tagged with its associated loop.)

> Beyond that, "name: for ..." or "for name ..." is, as you say, mostly a 
> matter of taste.  (There are proposals for both versions, and you can 
> look them up to see the arguments.)

The second form allows for those label names to be special, for example 
by belonging in the same name space as regular identifiers and thus 
subject to block scope rules. This is a tidier solution to the above.

Re: Taming The Switch-Statement
#493
Author: David Brown
Date: Sun, 18 Oct 2026 11:22
81 lines
4577 bytes
On 17/10/2026 13:34, bart wrote:
> On 17/10/2026 04:19, Dan Cross wrote:
>> In article <11auad0$3no1k$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
> 
>>> Those are considered more productive.
>>
>> ...and you think that's because of the syntax, and not the high
>> level nature of those languages?
> 
> It's a combination.
> 
>> Yes, the syntax is pretty gnarly; Dennis Ritchie even said as
>> much.  Fixed in Go and Rust, but also, I doubt you've ever in
>> your life had a variable of type array of array of length 8 of
>> a pointer to a pointer to a function returning an array of
>> pointers to char.  Finding the most ridiculous example you can
>> is not really evidence of anything besides your weird obsession
> 
> That was the first one I saw online next to a quote from K&R and I 
> assumed it was from the book. In fact the example from the book is this:
> 
>    char (*(*x())[])()
> 
> I've no idea what the means either. The point is not that the examples 
> are ridiculous, but that they are hard to convert to and from LTR form 
> which is how we think. With LTR syntax it becomes utterly trivial to 
> read or write them, no matter how complex.
> 
> (There's a tool called CDECL that translates types from C syntax to LTR 
> English or vice versa. It calls the C versions 'gibberish'. This is a 
> real thing!)
> 

Putting that example in cdecl gives :

"declare x as function returning pointer to array of pointer to function 
returning char"

To me, that is just as much gibberish as the original C.  No syntax is 
going to make sense of it - no amount of "ref" or "func" or pre-fix 
array notation will help.

If you want complex types in a programming language, make them out of 
simpler, named types that express what you are trying to achieve.  I 
think any decent typed programming language will have a way to do this - 
for C, "typedef" is your friend here.

(And do /not/ reply by bringing up examples you have cherry-picked from 
code you have found, as though it was my fault they wrote 
incomprehensible code.)


> 
>> with finding abstruse corner cases and holding them up as
>> reasons to dislike C.
> 
> The first example I gave was the simplest form of function pointer, 
> where the syntax is 'void(*)(void)'. Hardly a corner case, and it 
> rapidly goes downhill.

Name the types at the point where they are clear, and build them up from 
there.

	typedef void (*fp_void)(void);



> 
> If meeting C for the first time, that does not bode well. If the 
> designers did not care about this, that does not inspire confidence in 
> the rest of the language.

C is not, and has never claimed to be, a beginner-friendly language.  It 
is designed to be efficient while remaining quite a small language, 
which means that there are parts that are harder to use correctly, 
details that are important to understand, and it has plenty of scope to 
write code that is unclear.  It works well for responsible programmers 
who learn the language and code carefully - but you have to learn more 
before you can understand and use it than, say, BASIC or Python.

Re: Taming The Switch-Statement
#494
Author: Janis Papanagnou
Date: Sun, 18 Oct 2026 11:39
94 lines
5466 bytes
On 2026-10-18 12:48, David Brown wrote:
> On 17/10/2026 01:29, Janis Papanagnou wrote:
>> On 2026-10-17 00:00, Keith Thompson wrote:
>>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>> [...]
>>>>> There's a proposal for C2y to use goto labels as loop names, and a
>>>>> competing one to define a new syntax like "for NAME (;;)" :
>>>>> [...]
>>>>
>>>> I'm not particularly a fan of multi-level break/continue.  But if
>>>> we're going to have one of these, the second ("for NAME (;;)") is
>>>> unquestionably better.
>>>
>>> Unquestionably?  Why?
>>
>> Why would one question an opinion? ;-)
> 
> Time didn't word it as a personal opinion - he made it clear that he 
> doesn't think anyone else could have a different opinion.

You've noticed my smiley? (There was no need for an explanation.)

> 
> The C standards committee collectively reached an agreement counter to 
> Tim's thoughts, so clearly his preferred variant is /not/ unquestionably 
> better.

"C" is "C", and Tim is Tim. (And we know both sufficiently.) :-)

> 
>>
>>>
>>> I do like the fact that it doesn't conflate goto labels with loop
>>> names, but I still prefer the "NAME: for (;;)" form, partly because
>>> it's consistent with several other languages.
>>
>> I've no strong opinion on that, but I find the "for NAME (;;)" to
>> clearer express the _local scope_ of embedded breaks or continues.
>> (Just a matter of taste, and my appreciation for locality.)
>>

(I interpret your following explanations as additional information.)

> A main objection to "name: for ..." is that with function-scope labels, 
> you need a new name for every labelled loop or switch.  That may be an 
> inconvenience, especially for macro with labelled loops, or for copy- 
> and-paste code.  There is a proposal to deal with that which basically 
> says :
> 
> 1. Any "break label;" or "continue label;" refers to the innermost 
> containing loop or switch with that label.
> 
> 2. Any "label" used in "goto label;" must be unique in the function.
> 
> Those rules give a simple and intuitive fix without affecting existing 
> code.

Yes.

> 
> Beyond that, "name: for ..." or "for name ..." is, as you say, mostly a 
> matter of taste.  (There are proposals for both versions, and you can 
> look them up to see the arguments.)

Thanks. I'm interested, but (given what I think about it) not that
much. :-)

> 
>>
>> As far as I recall, in "C", the name of the function was often put
>> separately (first in the line) to have an easy method to find its
>> declaration by simple "grep ^fname". (With any sophisticated editor
>> this might be a weak argument, though.)
>>
> 
> I think it was popularised with a shortcut in emacs.

Well, I don't know what Emacs supports, or what it doesn't support so
that it requires some workaround, or shortcut, or explicit help from
the programmers concerning the layout.

I was using Vi for decades and with a search command ('/') you can do
a regexp '/^fname' to find fname at the start of a line. But there's
also "ctags" that can be used to facilitate that (and more). Recently
(i.e. since 25+ years) I'm using Vim where there's additional facilities
like the commands 'gd' (and 'gD') to jump to the local (and "global")
declaration of an entity; the latter don't require a tags-database or
any specific source code formatting to find the names.

Personally I've never followed the function-type-on-an-own-line style.

Janis
Re: Taming The Switch-Statement
#495
Author: David Brown
Date: Sun, 18 Oct 2026 12:09
132 lines
6776 bytes
On 18/10/2026 13:04, bart wrote:
> On 18/10/2026 11:48, David Brown wrote:
>> On 17/10/2026 01:29, Janis Papanagnou wrote:
> 
>>> I've no strong opinion on that, but I find the "for NAME (;;)" to
>>> clearer express the _local scope_ of embedded breaks or continues.
>>> (Just a matter of taste, and my appreciation for locality.)
>>>
>>
>> A main objection to "name: for ..." is that with function-scope 
>> labels, you need a new name for every labelled loop or switch.  That 
>> may be an inconvenience, especially for macro with labelled loops, or 
>> for copy- and-paste code.  There is a proposal to deal with that which 
>> basically says :
>>
>> 1. Any "break label;" or "continue label;" refers to the innermost 
>> containing loop or switch with that label.
>>
>> 2. Any "label" used in "goto label;" must be unique in the function.
>>
>> Those rules give a simple and intuitive fix without affecting existing 
>> code.
> 
> 

For reference:

<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3658.htm>

> There's something missing. Labels usually live in their own, function- 
> wide name space.
> 
> But if you have two loops like this:
> 
>     L1: while () {} L2:
>     L1: while () {} L2:
> 
> Then even if no gotos exist to L1, is that rule somehow relaxed for 
> those L1s to allow them to co-exist? (While still applying to non-loop 
> labels L2, which would clash.)

Fair questions.

The rules (as given in proposal N3658) apply to all labels.

The point of the proposal is to look at how the labels are /used/, not 
how they are defined, and make sure their /use/ is clear, intuitive, 
intended, and unambiguous.

The two "L2:" labels above would not be a problem unless there is a 
"goto L2" somewhere - then it is unclear which "L2" is being referenced, 
and it is the use of "goto L2" that means the duplication is flagged as 
an error.

The two "L1:" labels above would also constitute an error if you have 
"goto L1" in the function.

But if you have "break L1" or "continue L1" within the body of one of 
the loops, it is entirely clear which L1 is being referred to - and thus 
there is no error.


> 
> Will the L1s still live within the regular name space? (Presumably each 
> will now be tagged with its associated loop.)

No - with this change, labels do not have "scope" in the same way as 
before, but context-dependent lookup.

Note that if you have "L1: while () {}", and no other label "L1", then 
you can happily use "goto L1" from anywhere in the function (assuming 
you don't fall foul of other rules) - the label "L1" is /not/ in a local 
scope within the loop.

> 
>> Beyond that, "name: for ..." or "for name ..." is, as you say, mostly 
>> a matter of taste.  (There are proposals for both versions, and you 
>> can look them up to see the arguments.)
> 
> The second form allows for those label names to be special, for example 
> by belonging in the same name space as regular identifiers and thus 
> subject to block scope rules. This is a tidier solution to the above.
> 

Yes, the "for name ..." form makes label names special.  No, it is not a 
"tidier solution" - though of course you are welcome to a personal 
opinion that you think one syntax variant is nicer than the other. 
There are pros and cons of each syntax - that's why its important that 
there is a committee (two committees, actually, since both C and C++ are 
working on this) rather than having one person declare "this is clearly 
the best".  (Just so you know I am not picking on you - in another post 
I also said Tim was wrong to say "for name ..." was "unquestionably 
better".  And I am /not/ suggesting that "label: for ..." is 
unquestionably better either.)


See :

<https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3568r0.html#opposition-to-n3377>

(That is a C++ proposal, but discussions have gone back and forth 
between both C and C++ standards groups because the changes can apply to 
both languages - and no one wants different syntaxes for identical 
features.)


A key point is that labels of the form "L1: ..." are already familiar in 
C and many other programming languages, and a large number of other 
languages support something akin to "L1: while (..) { ... break L1; }".

Additionally, "L1 : do { ... break L1; } while (...)" puts the name at 
the top of the loop, rather than at the end (if it is attached to the 
"while").  (I don't know why N3377 proposed "do { } while NAME ( )" 
rather than "do NAME { } while ( )". )


And for those that like to use macros for their loops, the prefix label 
is neater:

	#define FOR_LOOP(_i, _n) for (int _i; i = 0; i < _n)

	outer : FOR_LOOP(i, 100) {
		inner : FOR_LOOP(j, 100) {
			if (i * j == 45) break outer;
		}
	}





Re: Taming The Switch-Statement
#496
Author: Janis Papanagnou
Date: Sun, 18 Oct 2026 12:12
56 lines
3680 bytes
On 2026-10-18 13:22, David Brown wrote:
> On 17/10/2026 13:34, bart wrote:
>> [...]
>>    char (*(*x())[])()
>> [...]
> 
> Putting that example in cdecl gives :
> 
> "declare x as function returning pointer to array of pointer to function 
> returning char"

There's different things here with the C-declaration.
* Complexity of expression; as you say below this can be alleviated by
    structuring with "subtypes" and 'typedef'.
* Cryptic syntax with many (spurious but in "C" necessary) parenthesis.
* Mixed/mangled order of component concerning its logical structure.

The 'cdecl' tool helps with point 2 and 3. - So I consider it to be
quite useful! (Although I have to admit that I've never used it myself
in practice because (for my code) I try to not compose overly complex
type definitions; and when it gets complex point 1 applies.) Especially
if you have to work with third-party code it can spare you some time,
though.

> 
> To me, that is just as much gibberish as the original C.  No syntax is 
> going to make sense of it - no amount of "ref" or "func" or pre-fix 
> array notation will help.

I assume you're here commenting on some of bart's adopted syntactical
decisions.

FWIW; why I prefer some other language design decisions is exactly that
they use syntaxes with such keywords. They typically reduce the number
of parentheses and other "graph" characters thereby reducing the effect
of code appearing quickly more cryptic than necessary, they make the
definition more clear and better readable (IMO). Keeping (in addition)
the logical order of its components also helps IMO to easier understand
the declaration construct.

To be frank, it's beyond me why anyone wouldn't admire such consistent
declaration syntaxes. (And if bart has adopted those principles that's
certainly not a bad thing. YMMV.)

> 
> If you want complex types in a programming language, make them out of 
> simpler, named types that express what you are trying to achieve.  I 
> think any decent typed programming language will have a way to do this - 
> for C, "typedef" is your friend here.

Yes. This is what we can do about the "complexity" aspect of the topic.

Janis

> [snip]
Re: Taming The Switch-Statement
#497
Author: David Brown
Date: Sun, 18 Oct 2026 12:18
34 lines
3300 bytes
On 16/10/2026 23:22, Tim Rentsch wrote:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> 
>> I find "break NAME;", where "NAME" is the name of an enclosing
>> construct, unambiguously better than "break N;", where N is the
>> number of levels to break out of. [...]
> 
> Definitely.
> 
>> There's a proposal for C2y to use goto labels as loop names, and a
>> competing one to define a new syntax like "for NAME (;;)" :
>>
>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm
>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3377.pdf
> 
> I'm not particularly a fan of multi-level break/continue.  But if
> we're going to have one of these, the second ("for NAME (;;)") is
> unquestionably better.

Given the number of questions asked, the various proposals for labelled 
break and continue in both C and C++, and the fact that the C standards 
committee have already chosen "name: for (...)" as their syntax, you are 
unquestionably wrong to say that the second form is "unquestionably 
better".  Indeed, you would also have been wrong had you said the first 
form is "unquestionably better".

You can have your opinion, and you can have justification for that 
opinion, but it is not fact, and it is not unquestionable.  There are 
pros and cons of both variants, and different people will put different 
weightings on which of those are most important to them personally - or 
which they think will be most important for the language and programmer 
community in general.

Re: Taming The Switch-Statement
#498
Author: David Brown
Date: Sun, 18 Oct 2026 12:32
37 lines
2992 bytes
On 17/10/2026 22:40, bart wrote:
> On 17/10/2026 18:58, Dan Cross wrote:
>> In article <11avmfb$55rt$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>>> On 17/10/2026 04:19, Dan Cross wrote:
>>>> In article <11auad0$3no1k$1@dont-email.me>, bart  <bc@freeuk.com> 
>>>> wrote:

>> Yes.  C's declaration syntax is famously abstruse; film at 11.

I'm not sure it is.  It is different from what you find in some other 
languages, and it is certainly possible to write declarations in C that 
are hard to comprehend.  But it is possible to do that in any 
programming language, and equally you can write clear declarations in C. 
  It is very rare that I have to think about the syntax of declarations 
when I write C code, or when I read C code - maybe that's just my own 
experience, but it is simply not an issue for me.  Mind you, I don't 
write code with the rubbish that you bring up as "examples" - maybe my 
experience is different from that of other people.

> 
> And ... that's it? Just accept it? How about doing something about it!
> 

What, exactly, do you think any of us should do about it?  Let's hear a 
clear, realistic, concrete plan for how people here, the readers of 
comp.lang.c, can go about changing the syntax for C declarations.

Note that continually posting complaints to people who did not design 
the C language, do not implement C compilers, and are not part of the C 
standards committee, is not a realistic or concrete plan for change.

Nor is continually badgering people to "admit" that C is a terrible 
language.



Re: Taming The Switch-Statement
#499
Author: Janis Papanagnou
Date: Sun, 18 Oct 2026 12:34
17 lines
2585 bytes
On 2026-10-18 14:09, David Brown wrote:
> 
> [...]  (I don't know why N3377 proposed "do { } while NAME ( )"
> rather than "do NAME { } while ( )". )

Oh! - I can only think that it would then be (sort of) "consistent"
with the place of the label attacked in a 'while' loop; i.e. behind
the 'while' keyword. - It's inconsistent in another interpretation,
though; and I'd certainly have favored the latter form, to have the
label consistently attached at the loop-entry keyword.
We'll see what they finally decide (unless it's already clear; I'm
not sure about the factual weight of the "proposal")...

Janis

> [...]
Re: Taming The Switch-Statement
#501
Author: bart
Date: Sun, 18 Oct 2026 13:33
159 lines
7408 bytes
On 18/10/2026 12:22, David Brown wrote:
> On 17/10/2026 13:34, bart wrote:
>> On 17/10/2026 04:19, Dan Cross wrote:
>>> In article <11auad0$3no1k$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>>
>>>> Those are considered more productive.
>>>
>>> ...and you think that's because of the syntax, and not the high
>>> level nature of those languages?
>>
>> It's a combination.
>>
>>> Yes, the syntax is pretty gnarly; Dennis Ritchie even said as
>>> much.  Fixed in Go and Rust, but also, I doubt you've ever in
>>> your life had a variable of type array of array of length 8 of
>>> a pointer to a pointer to a function returning an array of
>>> pointers to char.  Finding the most ridiculous example you can
>>> is not really evidence of anything besides your weird obsession
>>
>> That was the first one I saw online next to a quote from K&R and I 
>> assumed it was from the book. In fact the example from the book is this:
>>
>>    char (*(*x())[])()
>>
>> I've no idea what the means either. The point is not that the examples 
>> are ridiculous, but that they are hard to convert to and from LTR form 
>> which is how we think. With LTR syntax it becomes utterly trivial to 
>> read or write them, no matter how complex.
>>
>> (There's a tool called CDECL that translates types from C syntax to 
>> LTR English or vice versa. It calls the C versions 'gibberish'. This 
>> is a real thing!)
>>
> 
> Putting that example in cdecl gives :
> 
> "declare x as function returning pointer to array of pointer to function 
> returning char"
> 
> To me, that is just as much gibberish as the original C.

That doesn't matter - the problem is not even knowing what it 
represents. (That it is an actual function is a surprise. That you can't 
easily tell is crazy.)

In practice there will be actual types that start to look like 
gibberish, full of *, () and [] that must be in exactly the right place.

Then maybe you want to construct a pointer to such a type or an array of 
it - where will be the new * or [] go? Where will the variable name go 
for that matter?

This should be simple enough to do in a language without needing to 
follow some back-and-forth algorithm, or use an external tool, or need 
to decompose them into multiple levels using 'typedef', or need to 
disambiguate with parentheses.

Typedef decomposition can be useful when types are genuinely complex (or 
parts of them are used/shared elsewhere), but it should not be a crutch 
for an unusable type syntax.

In any case, for me the threshold at which I need help is low. I 
couldn't do these for example:

  * Array of function pointers (say taking no params and returning void)
  * Pointer to array of function pointers
  * Function returning pointer to array (of int)
  * Pointer to function returning pointer to array (int)

My tool tells me the answers are these:

   void (*[])(void)
   void (*(*)[])(void)
   int (*(void))[]
   int (*(*)(void))[]

Still gobbledygook, sorry, and these are hardly that complex or 
unrealistic. (Other than 'pointer to array' being an uncommon C idiom. 
It's only uncommon because other C syntax choices make it ungainly to 
work with.)

Of those four lines, one is an actual function; another is a pointer to 
a function. Plus there is an array, and a pointer to something else. But 
this is not obvious at a glance, because the key part is buried in the 
middle. In an LTR scheme, it would be first.

> No syntax is 
> going to make sense of it - no amount of "ref" or "func" or pre-fix 
> array notation will help.

It will tell you what it is, which is a start. Those four examples I 
gave would look like this:

   []ref proc               # 'proc' is 'func -> void'
   ref []ref proc
   func -> ref []int
   ref func -> ref []int

Using a scheme I once proposed for C, to work side-by-side with the 
current syntax, I believe it would be like this:

   []*func()void
   *[]*func()void p, q;
   func F()*[]int {}
   *func()*[]int

Variable names would go on the right as in the second example. For that 
actual function however, an earlier name looks better and matches other 
languages.

> If you want complex types in a programming language, make them out of 
> simpler, named types that express what you are trying to achieve.  I 
> think any decent typed programming language will have a way to do this - 
> for C, "typedef" is your friend here.
> 
> (And do /not/ reply by bringing up examples you have cherry-picked from 
> code you have found, as though it was my fault they wrote 
> incomprehensible code.)

But that is going to happen. You will come across such types.

> C is not, and has never claimed to be, a beginner-friendly language.

If something is needlessly complex and unintuitive, that will be the 
case for everyone.

For beginners to C, it is just an unnecessary obstacle. I can see many 
giving up on it for that reason.

One way to simplify types is to use 'typeof' (I've no idea whether it is 
still an extension or now standardised). That means being able to write:

    typeof(int*) p, q, r;

instead of: 'int *p, *q, *r' which is too tempting to write as 'int* p, 
q, r'.

This solves another issue where the type of any declared variable is 
split up into up three pieces in three different places:

    int a, b, *c[10];


The type of 'c' comprises 'int', '*' before the name, and '[]' after the 
name. This makes it hard to share too. 'typeof' allows this (or along 
these lines):

    typeof(int*[]) x, y, z;

The type is in one tidy place, and it can be shared. This is how C 
should have worked in the first place, and it wouldn't have needed that 
untidy 'typeof()'.


>  It 
> is designed to be efficient while remaining quite a small language, 

C's type declarations are actually harder to parse than a conventional 
LTR scheme. That means a more complex compiler front-end.
Re: Taming The Switch-Statement
#502
Author: Michael S
Date: Sun, 18 Oct 2026 14:13
30 lines
3018 bytes
On Sun, 18 Oct 2026 14:34:28 +0200
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

> On 2026-10-18 14:09, David Brown wrote:
> > 
> > [...]  (I don't know why N3377 proposed "do { } while NAME ( )"
> > rather than "do NAME { } while ( )". )  
> 
> Oh! - I can only think that it would then be (sort of) "consistent"
> with the place of the label attacked in a 'while' loop; i.e. behind
> the 'while' keyword. - It's inconsistent in another interpretation,
> though; and I'd certainly have favored the latter form, to have the
> label consistently attached at the loop-entry keyword.

I'd prefer label consistently attached to the loop-exit keyword.
Unfortunately, for() and while() loops have no such keyword.

> We'll see what they finally decide (unless it's already clear; I'm
> not sure about the factual weight of the "proposal")...
> 

I tend to agree with Tim (if I correctly understood him): a.t.m. the
best outcome would be proposal scrapped completely.

> Janis
> 
> > [...]  
> 

Re: Taming The Switch-Statement
#503
Author: Michael S
Date: Sun, 18 Oct 2026 14:24
19 lines
2054 bytes
On Sun, 18 Oct 2026 13:22:52 +0200
David Brown <david.brown@hesbynett.no> wrote:

> 
> To me, that is just as much gibberish as the original C.  No syntax
> is going to make sense of it - no amount of "ref" or "func" or
> pre-fix array notation will help.
> 

[O.T.]
Prefix array notation would not. But postfix * notation would, somewhat.

It would be interesting to find out why designers of C, or of one of its
ancestors decided that * as prefix is preferable to * as postfix.
Were they afraid of confusion with usage of * as multiplication?
Probably not, because confusion can arise about equally both for prefix
and for postfix.

Re: Taming The Switch-Statement
#504
Author: David Brown
Date: Sun, 18 Oct 2026 14:27
97 lines
5619 bytes
On 18/10/2026 15:33, bart wrote:
> On 18/10/2026 12:22, David Brown wrote:
>> On 17/10/2026 13:34, bart wrote:
>>> On 17/10/2026 04:19, Dan Cross wrote:
>>>> In article <11auad0$3no1k$1@dont-email.me>, bart  <bc@freeuk.com> 
>>>> wrote:
>>>
>>>>> Those are considered more productive.
>>>>
>>>> ...and you think that's because of the syntax, and not the high
>>>> level nature of those languages?
>>>
>>> It's a combination.
>>>
>>>> Yes, the syntax is pretty gnarly; Dennis Ritchie even said as
>>>> much.  Fixed in Go and Rust, but also, I doubt you've ever in
>>>> your life had a variable of type array of array of length 8 of
>>>> a pointer to a pointer to a function returning an array of
>>>> pointers to char.  Finding the most ridiculous example you can
>>>> is not really evidence of anything besides your weird obsession
>>>
>>> That was the first one I saw online next to a quote from K&R and I 
>>> assumed it was from the book. In fact the example from the book is this:
>>>
>>>    char (*(*x())[])()
>>>
>>> I've no idea what the means either. The point is not that the 
>>> examples are ridiculous, but that they are hard to convert to and 
>>> from LTR form which is how we think. With LTR syntax it becomes 
>>> utterly trivial to read or write them, no matter how complex.
>>>
>>> (There's a tool called CDECL that translates types from C syntax to 
>>> LTR English or vice versa. It calls the C versions 'gibberish'. This 
>>> is a real thing!)
>>>
>>
>> Putting that example in cdecl gives :
>>
>> "declare x as function returning pointer to array of pointer to 
>> function returning char"
>>
>> To me, that is just as much gibberish as the original C.
> 
> That doesn't matter - the problem is not even knowing what it 
> represents. 

That is, shall we say, a strange attitude.  Gibberish (since that seems 
to be the preferred term here) is gibberish, no matter the language or 
representation, and is equally meaningless and useless.

> (That it is an actual function is a surprise. That you can't 
> easily tell is crazy.)

You can tell it very easy from the C - the final bit is parentheses.

> 
> In practice there will be actual types that start to look like 
> gibberish, full of *, () and [] that must be in exactly the right place.

Not in my code, or the code I work with - types are clear to me.  Again, 
experiences can vary.  (Of course the syntactical elements must be in 
the right place!)

> 
> Then maybe you want to construct a pointer to such a type or an array of 
> it - where will be the new * or [] go? Where will the variable name go 
> for that matter?

Use a typedef.  Or since C23, use type inference - that can save naming 
and identifying types when things get complex, and makes it easier to 
write more general code.  Like all language features, there are times 
when it is appropriate, and times when it is inappropriate.  But if 
you've got something "foo" (an object, function, type, etc.) and you 
want an array of 26 of that type, type inference makes that simple - the 
type of "foo" is "typeof(foo)" :

	typeof(foo) xs[26];

If you want a pointer to the object "foo", "auto * p = &foo;".  This is, 
IMHO, a nice addition in C23, but it would have been nicer to have had 
it earlier.  (It's been a gcc extension for a long time.)

> 
> This should be simple enough to do in a language without needing to 
> follow some back-and-forth algorithm, or use an external tool, or need 
> to decompose them into multiple levels using 'typedef', or need to 
> disambiguate with parentheses.

You just /have/ to whine, don't you?  Whenever you complain - usually 
due to ignorance or prejudice - that something is difficult or 
complicated in C, and someone tells you how it can be handled simply and 
clearly, you are unable to simply say "Okay, thanks - that's good to 
know" or "Sorry, I was wrong, I thought it was hard".  You can't help 
but call things workarounds, or complicated, or get your knickers in a 
twist about having to use a language feature that for some reason you hate.

Re: Taming The Switch-Statement
#508
Author: David Brown
Date: Sun, 18 Oct 2026 14:52
41 lines
3905 bytes
On 18/10/2026 16:13, Michael S wrote:
> On Sun, 18 Oct 2026 14:34:28 +0200
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> 
>> On 2026-10-18 14:09, David Brown wrote:
>>>
>>> [...]  (I don't know why N3377 proposed "do { } while NAME ( )"
>>> rather than "do NAME { } while ( )". )
>>
>> Oh! - I can only think that it would then be (sort of) "consistent"
>> with the place of the label attacked in a 'while' loop; i.e. behind
>> the 'while' keyword. - It's inconsistent in another interpretation,
>> though; and I'd certainly have favored the latter form, to have the
>> label consistently attached at the loop-entry keyword.
> 
> I'd prefer label consistently attached to the loop-exit keyword.
> Unfortunately, for() and while() loops have no such keyword.
> 

That would help for switch inside a loop, or loop inside a switch, but 
do nothing for loop inside a loop or switch inside a switch.  I don't 
think anyone involved in the development of the language has seriously 
considered making a solution that only handles the first two cases, and 
not the second two (to say nothing of three or more nesting layers). 
"break_switch" and "break_loop" style solutions have been mentioned and 
quickly dismissed, along with the "break <depth>" options.

>> We'll see what they finally decide (unless it's already clear; I'm
>> not sure about the factual weight of the "proposal")...
>>
> 
> I tend to agree with Tim (if I correctly understood him): a.t.m. the
> best outcome would be proposal scrapped completely.
> 

The proposal has been accepted - it is coming to C and C++, whatever you 
or Tim may think.  But of course there is no requirement to /use/ the 
new feature if you don't like it.  (I don't expect to use it 
significantly myself - I just don't seem to write code in a way that 
could take advantage of it.)
Re: Taming The Switch-Statement
#509
Author: David Brown
Date: Sun, 18 Oct 2026 14:58
29 lines
2614 bytes
On 18/10/2026 16:24, Michael S wrote:
> On Sun, 18 Oct 2026 13:22:52 +0200
> David Brown <david.brown@hesbynett.no> wrote:
> 
>>
>> To me, that is just as much gibberish as the original C.  No syntax
>> is going to make sense of it - no amount of "ref" or "func" or
>> pre-fix array notation will help.
>>
> 
> [O.T.]
> Prefix array notation would not. But postfix * notation would, somewhat.
> 

I can agree that notational changes might make it marginally easier to 
understand complex declarations - or mean that declarations could be 
marginally more complex while still being easily understood.  But 
nothing can make Bart's exaggerated examples meaningful.

> It would be interesting to find out why designers of C, or of one of its
> ancestors decided that * as prefix is preferable to * as postfix.
> Were they afraid of confusion with usage of * as multiplication?
> Probably not, because confusion can arise about equally both for prefix
> and for postfix.
> 

I don't know why it is prefix.  Maybe they were keen on "*p++ = *q++" 
and similar expressions, felt "(p++)* = (q++)*" was unclear?
Re: Taming The Switch-Statement
#511
Author: Michael S
Date: Sun, 18 Oct 2026 15:16
70 lines
4789 bytes
On Sun, 18 Oct 2026 16:52:17 +0200
David Brown <david.brown@hesbynett.no> wrote:

> On 18/10/2026 16:13, Michael S wrote:
> > On Sun, 18 Oct 2026 14:34:28 +0200
> > Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> >   
> >> On 2026-10-18 14:09, David Brown wrote:  
> >>>
> >>> [...]  (I don't know why N3377 proposed "do { } while NAME ( )"
> >>> rather than "do NAME { } while ( )". )  
> >>
> >> Oh! - I can only think that it would then be (sort of) "consistent"
> >> with the place of the label attacked in a 'while' loop; i.e. behind
> >> the 'while' keyword. - It's inconsistent in another interpretation,
> >> though; and I'd certainly have favored the latter form, to have the
> >> label consistently attached at the loop-entry keyword.  
> > 
> > I'd prefer label consistently attached to the loop-exit keyword.
> > Unfortunately, for() and while() loops have no such keyword.
> >   
> 
> That would help for switch inside a loop, or loop inside a switch,
> but do nothing for loop inside a loop or switch inside a switch.  I
> don't think anyone involved in the development of the language has
> seriously considered making a solution that only handles the first
> two cases, and not the second two 

Pay attention that 4 patterns are not equal. The second case
(breaking from loop to outside of containing switch) hardly happens.

> (to say nothing of three or more
> nesting layers). "break_switch" and "break_loop" style solutions have
> been mentioned and quickly dismissed, along with the "break <depth>"
> options.
> 

It does not look like you understood what I wrote.
All I wanted to say is that I prefer label to be located at where the
break goes. Or near this point. Within frame of current C syntax, I
don't see how to achieve it, except for do-while. But it does not
change the fact that I find it desirable.

> >> We'll see what they finally decide (unless it's already clear; I'm
> >> not sure about the factual weight of the "proposal")...
> >>  
> > 
> > I tend to agree with Tim (if I correctly understood him): a.t.m. the
> > best outcome would be proposal scrapped completely.
> >   
> 
> The proposal has been accepted - it is coming to C and C++, whatever
> you or Tim may think.

Nothing is set in stone until the standard released. But you are very
likely right. Which does not make me happier.

>  But of course there is no requirement to /use/
> the new feature if you don't like it. 

But others will use it and I'd have to read and understand their code.

> (I don't expect to use it 
> significantly myself - I just don't seem to write code in a way that 
> could take advantage of it.)
>



Re: Taming The Switch-Statement
#512
Author: Michael S
Date: Sun, 18 Oct 2026 15:26
35 lines
2791 bytes
On Sun, 18 Oct 2026 16:58:38 +0200
David Brown <david.brown@hesbynett.no> wrote:

> On 18/10/2026 16:24, Michael S wrote:
> > On Sun, 18 Oct 2026 13:22:52 +0200
> > David Brown <david.brown@hesbynett.no> wrote:
> >   
> >>
> >> To me, that is just as much gibberish as the original C.  No syntax
> >> is going to make sense of it - no amount of "ref" or "func" or
> >> pre-fix array notation will help.
> >>  
> > 
> > [O.T.]
> > Prefix array notation would not. But postfix * notation would,
> > somewhat. 
> 
> I can agree that notational changes might make it marginally easier
> to understand complex declarations - or mean that declarations could
> be marginally more complex while still being easily understood.  But 
> nothing can make Bart's exaggerated examples meaningful.
> 
> > It would be interesting to find out why designers of C, or of one
> > of its ancestors decided that * as prefix is preferable to * as
> > postfix. Were they afraid of confusion with usage of * as
> > multiplication? Probably not, because confusion can arise about
> > equally both for prefix and for postfix.
> >   
> 
> I don't know why it is prefix.  Maybe they were keen on "*p++ = *q++" 
> and similar expressions, felt "(p++)* = (q++)*" was unclear?
> 

Why would it require parentheses? 
Re: Taming The Switch-Statement
#513
Author: Janis Papanagnou
Date: Sun, 18 Oct 2026 15:49
35 lines
3509 bytes
On 2026-10-18 16:13, Michael S wrote:
> On Sun, 18 Oct 2026 14:34:28 +0200
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>> On 2026-10-18 14:09, David Brown wrote:
>>>
>>> [...]  (I don't know why N3377 proposed "do { } while NAME ( )"
>>> rather than "do NAME { } while ( )". )
>>
>> Oh! - I can only think that it would then be (sort of) "consistent"
>> with the place of the label attacked in a 'while' loop; i.e. behind
>> the 'while' keyword. - It's inconsistent in another interpretation,
>> though; and I'd certainly have favored the latter form, to have the
>> label consistently attached at the loop-entry keyword.
> 
> I'd prefer label consistently attached to the loop-exit keyword.

I can see that this might look appealing in case of 'break'. In
case of the same mechanism working also for 'continue' I'd then
think that it should generally better be an "attribute" of the
loop entry keyword, i.e. placed where loops start. (But that's
just my opinion.) Having it at a different place with a do-loop
I consider a really bad decision. It's advantageous to know the
direction in which to seek for the label if you inspect code. -
But okay, it's "C"; I won't heat up about some future C-release
that I'll never use (especially given that I'm not even be using
all of those more recent additions that are already available).

> Unfortunately, for() and while() loops have no such keyword.

Or fortunately. ;-)

Janis

> [...]
Re: Taming The Switch-Statement
#514
Author: bart
Date: Sun, 18 Oct 2026 16:09
116 lines
5805 bytes
On 18/10/2026 15:27, David Brown wrote:
> On 18/10/2026 15:33, bart wrote:
>> On 18/10/2026 12:22, David Brown wrote:

>>> To me, that is just as much gibberish as the original C.
>>
>> That doesn't matter - the problem is not even knowing what it represents. 
> 
> That is, shall we say, a strange attitude.  Gibberish (since that seems 
> to be the preferred term here) is gibberish, no matter the language or 
> representation, and is equally meaningless and useless.

'Gibberish' here refers to the representation, whether the type being 
described is made-up nonsense or real.

You may want to know what some complex type is for many reasons, you 
don't necessarily need to understand what it means or why it was used.

(For example I might come across a type in a C API that I want to 
convert to another language.)


>> (That it is an actual function is a surprise. That you can't easily 
>> tell is crazy.)
> 
> You can tell it very easy from the C - the final bit is parentheses.

Both actual function declarations and function pointers end in (...).

Function definitions will have { towards the end of the signature which 
is more of a clue.

But it is telling that pretty much every language using C-style syntax 
has chosen to use a keyword (fn, fun, func, function or other) to 
introduce a function signature.

>> In practice there will be actual types that start to look like 
>> gibberish, full of *, () and [] that must be in exactly the right place.
> 
> Not in my code, or the code I work with - types are clear to me.  Again, 
> experiences can vary.

What are you saying here, that your types never involve * () or []? That 
is hard to believe.

>  (Of course the syntactical elements must be in 
> the right place!)

Isn't that the problem? C makes it tricky. Here are two very 
straightforward declarations from my projects:

   ref []ichar stringtable               # ichar is ref char
   [N]ref proc(T) handlertable

These are the C versions:

   char *(*stringtable)[];
   void (*handlertable[N)(T);

They involve * () and [] that must all be in the right place, in the 
right nesting order. In C, parentheses are used to alter precedences as 
well as for parameter lists. This not a thing in LTR forms.

Additionally, in C, you can sometimes mix up the order of * and [], but 
since a T* value can be indexed, and a T[] value can be dereferenced, 
those errors might still compile.

So it's a problem. You're saying it isn't one if you do X, Y and Z. I'm 
  that you shouldn't need to do X, Y and Z; if you do then it's a 
language problem.


> Use a typedef.  Or since C23, use type inference - that can save naming 
> and identifying types when things get complex,

OK, that's a fifth kind of workaround! Although it is more of an 
unrelated feature.
>> This should be simple enough to do in a language without needing to 
>> follow some back-and-forth algorithm, or use an external tool, or need 
>> to decompose them into multiple levels using 'typedef', or need to 
>> disambiguate with parentheses.
> 
> You just /have/ to whine, don't you?  Whenever you complain - usually 

I thought it was, for a change, a civil exchange up to now.

I'm saying that type syntax should useful without having to resort to 
any of those four workarounds I mentioned.

If that happens because syntax choices (rather than genuine complexity) 
would otherwise result in gibberish, then that is a failing in the language.


> complicated in C, and someone tells you how it can be handled simply and 
> clearly,

No. Stuff like this is simple and clear:

   ref proc
   ref func -> void
   * func()void

Since whatever the type, you can always read off exactly what it is from 
left to right.

This is gibberish:

  void(*)(void)
  void(*)()                       (C23)

 >unable to simply say "Okay, thanks - that's good to > know" or "Sorry, 
I was wrong, I thought it was hard".  You can't help
> but call things workarounds, or complicated, or get your knickers in a 
> twist about having to use a language feature that for some reason you hate.
This one is universally disliked and even the language creators said it 
was a mistake. I didn't realise that opinion was even controversial.
Re: Taming The Switch-Statement
#515
Author: Janis Papanagnou
Date: Sun, 18 Oct 2026 16:11
35 lines
2966 bytes
On 2026-10-18 17:26, Michael S wrote:
> On Sun, 18 Oct 2026 16:58:38 +0200
> David Brown <david.brown@hesbynett.no> wrote:
>> On 18/10/2026 16:24, Michael S wrote:
[...]
>>> It would be interesting to find out why designers of C, or of one
>>> of its ancestors decided that * as prefix is preferable to * as
>>> postfix.

Because it is more "natural" when read, easier to grasp? Simpler
for compilers? More consistent if all other, especially standard
operators known from daily use are used in prefix-form (-5, +42,
!false, ~bitset) in expressions?

I don't recall to have used any language with infix-expressions
that would have their monadic operators defined in postfix form.
The only exception was "C" (and C-oriented languages) with their
special case of post-increment/post-decrement operators. (Think
also about the quirk in C++ to define monadic postfix operators
that require a syntactic dummy type argument). (In low-level RPN
systems it may appear more "natural", but that just aside.)

>>> Were they afraid of confusion with usage of * as
>>> multiplication? Probably not, because confusion can arise about
>>> equally both for prefix and for postfix.
>>
>> I don't know why it is prefix.  Maybe they were keen on "*p++ = *q++"
>> and similar expressions, felt "(p++)* = (q++)*" was unclear?
> 
> Why would it require parentheses?

Not necessarily (I think).

Janis
Page 5 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