Thread View: comp.lang.c
412 messages
412 total messages
Page 6 of 9
Started by Lawrence D’Oliveiro
Sat, 10 Oct 2026 00:25
Page 6 of 9 • 412 total messages
Re: Taming The Switch-Statement
Author: Michael S
Date: Sun, 18 Oct 2026 16:32
Date: Sun, 18 Oct 2026 16:32
57 lines
3392 bytes
3392 bytes
On Sun, 18 Oct 2026 18:11:18 +0200 Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: > 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? IMHO, no. >Simpler for compilers? 100% no. > More consistent if all other, especially standard > operators known from daily use are used in prefix-form (-5, +42, > !false, ~bitset) in expressions? Unary * is more similar in function to postfix operators like [] and () than to those you mentioned. > > I don't recall to have used any language with infix-expressions > that would have their monadic operators defined in postfix form. I am a Bear of Very Little Brain, and long words Bother Me. By chance, did you never use Pascal? > 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 >
Re: Taming The Switch-Statement
Author: bart
Date: Sun, 18 Oct 2026 17:34
Date: Sun, 18 Oct 2026 17:34
56 lines
3755 bytes
3755 bytes
On 18/10/2026 15: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. > > 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. With all the other questionable choices, there probably wasn't much rationale involved. And there seemed to be little oversight too: other people weighing in with their opinions. That particular choice had several consequences: * If P is a pointer to a struct, then you have to write (*P).m instead of P*.m. * That led to people using "->" instead (I don't know if that was introduced for this reason). But that only works for one level: (**Q).m still needs (*Q)->m. With postfix it's tidier and consistent: Q**.m * The same when P is a pointer to an array. Pointers to arrays (real ones of type (T(*)[] not the T* idiom), are rarely used in C, possibly for the reason that indexing would look like (*P)[i], instead of P[i]. With postfix, it would be the marginally tidier P*[i]. Although here, even if unambiguous, the use of "*" looks odd. In the event, everybody uses T* for 'array pointers' instead, which is less type-safe. With function pointer derefs, it would be P*(x) which /is/ ambiguous, although for some obscure reason, function pointers don't need to be dereferenced: P(x) would still work. * Then we get to type syntax. I think this simplifies a little: * and [] modifiers will always be to the right of a variable. Parentheses for precedence might disappear too. Types will be a little easier to get right and to grok. When C was created, Pascal with its '^' postfix deref op already existed. Although C claims to have some Algol 68 influence (I can't see it!) it seems to have ignored Pascal completely.
Re: Taming The Switch-Statement
Author: David Brown
Date: Sun, 18 Oct 2026 18:47
Date: Sun, 18 Oct 2026 18:47
130 lines
7501 bytes
7501 bytes
On 18/10/2026 17:16, Michael S wrote:
> 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.
>
I know they are not equal - that's why I wrote all four combinations.
But I have no good statistics to determine which combinations might be
more common than others for wanting to break out of the outer structure.
I know /you/ said that /you/ regularly want to break out of a switch
that is inside a loop - fair enough. It is not something that I have
needed to do, or at least not often enough to bother about it. Indeed,
none of the cases are particularly common in my code. I've no doubt
come across some of them at times, and dealt with them using extra bools
or splitting up big functions into smaller ones where "return" could do
the job. Certainly I do not ever remember wishing I had a "break_loop"
statement, or a labelled break.
But the C standards committee don't care about my code. They don't care
about your code either. They care about what they think makes a
difference to large numbers of C programmers. I can't tell you if they
have access to good statistics, or are using the combined gut feelings
of the committee members. However, it would strike me as a serious
wasted opportunity if they made an addition to the language that only
handled the one pattern that you find most common in your code, rather
than also making it work for the other patterns.
>> (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.
In C2y, you /do/ put the label along with the break - you write "break
outer;". But you also have to put the label "outer : " at the start of
the control structure.
If you want to have some kind of "break to outer structure" /without/
having a name or label on the structure, then you need some other way to
refer to it. I thought you had said before your preference was for
something like "break_switch" (ignoring any bike-shedding on the
syntax), which would work in the particular case of a switch with nested
loop(s). And as I wrote, this was considered and dismissed. (Equally,
the other plausible syntax that does not require an explicit label -
"break <depth>", was considered and dismissed.)
> 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.
>
Am I right in thinking you would then have :
do {
switch (...) {
break outer;
while outer (...);
You are happy with labelling the loop or switch, but want the label at
the end, not the start?
Why not then just use "goto" and put a label at the end of the loop or
switch? (This is allowed in C23.)
>>>> 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.
>
Okay. There are always changes that we like, changes we dislike, and
(often the majority) changes to which we are indifferent.
>> 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.
>
True - but do you /really/ think that is going to be a problem?
>> (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
Author: David Brown
Date: Sun, 18 Oct 2026 19:09
Date: Sun, 18 Oct 2026 19:09
149 lines
7198 bytes
7198 bytes
On 18/10/2026 18:09, bart wrote: > 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. > Maybe that's what /you/ mean by it, but to me the type itself there is gibberish - no matter what representation you use. > 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.) You are just making stuff up. C API's use different named types just like any other C code, so that people can understand what they are. > >>> 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. I'll cross off "false dichotomy" on my "Bart's logical fallacies" bingo card for the day. I don't write types that look like gibberish, full of *, () and []. That does not mean I do not write types that contain *, () or []. > >> (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 Are you suggesting that in your language, "stringtable" could also be declared as : ref ichar [stringtable] or ][ stringtable ichar ref ? I suspect that your language also requires the syntactical elements to be in the right place. > > 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. I assume that : [N] ref proc(T) handlertable and ref [N] proc(T) handlertable are different? You need to give things in the right order, or use parentheses, to get the right "type expression". It's just like any other kind of expression. The intention of the declaration syntax in C is that the declaration order follows usage. If you would not write code that /uses/ a declaration in a particular way - like so many *, () and [] sets that it is hard to comprehend - then do not write /declarations/ in that way. I don't think there is anything inherently better about C's declaration syntax than your declaration syntax, or others that are more right-to-left or more left-to-right. There's a lot of good things to say about left-to-right ordering, since that is the order for reading (in English, anyway). But it also means the declaration order and usage order are different unless your array subscript, pointer dereference and call operators are also all left-to-right. My point is not that C's syntax is wonderful (I disagree with Kenny here), but that it works fine in practice, you don't have to write incomprehensible declarations, and that if you /do/ want to write incomprehensible declarations, you can do it in any language just as easily. > > 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. > I know you say that - you are wrong to say that. If you want good, clear, correct C code, you need to write good, clear, correct C code. That's the X, Y and Z. And that applies to all languages, including yours. The details may differ, but the principles do not. You can well hold the opinion that you personally find it easier to write good, clear, correct code in your own language than you do in C. It would indeed be extraordinary if that were not the case. But your opinion there does not make it fact, or mean it applies to others. > >> 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. It was - I really am trying, but you wrote one knee-jerk comment too many. I will try to reset.
Re: Taming The Switch-Statement
Author: David Brown
Date: Sun, 18 Oct 2026 19:11
Date: Sun, 18 Oct 2026 19:11
42 lines
3179 bytes
3179 bytes
On 18/10/2026 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: >>> 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? > Maybe it would not - but I think perhaps "p++* = q++*" would be even less clear. But again, I have no idea here, and if dereferencing had been postfix, it might have had knock-on effects to other aspects of operator ordering or precedence.
Re: Taming The Switch-Statement
Author: Michael S
Date: Sun, 18 Oct 2026 19:38
Date: Sun, 18 Oct 2026 19:38
158 lines
8879 bytes
8879 bytes
On Sun, 18 Oct 2026 20:47:13 +0200
David Brown <david.brown@hesbynett.no> wrote:
> On 18/10/2026 17:16, Michael S wrote:
> > 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.
> >
>
> I know they are not equal - that's why I wrote all four combinations.
> But I have no good statistics to determine which combinations might
> be more common than others for wanting to break out of the outer
> structure. I know /you/ said that /you/ regularly want to break out
> of a switch that is inside a loop - fair enough. It is not something
> that I have needed to do, or at least not often enough to bother
> about it. Indeed, none of the cases are particularly common in my
> code. I've no doubt come across some of them at times, and dealt
> with them using extra bools or splitting up big functions into
> smaller ones where "return" could do the job. Certainly I do not
> ever remember wishing I had a "break_loop" statement, or a labelled
> break.
>
> But the C standards committee don't care about my code. They don't
> care about your code either. They care about what they think makes a
> difference to large numbers of C programmers. I can't tell you if
> they have access to good statistics, or are using the combined gut
> feelings of the committee members. However, it would strike me as a
> serious wasted opportunity if they made an addition to the language
> that only handled the one pattern that you find most common in your
> code, rather than also making it work for the other patterns.
>
> >> (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.
>
> In C2y, you /do/ put the label along with the break - you write
> "break outer;". But you also have to put the label "outer : " at the
> start of the control structure.
>
> If you want to have some kind of "break to outer structure" /without/
> having a name or label on the structure, then you need some other way
> to refer to it. I thought you had said before your preference was
> for something like "break_switch" (ignoring any bike-shedding on the
> syntax), which would work in the particular case of a switch with
> nested loop(s). And as I wrote, this was considered and dismissed.
> (Equally, the other plausible syntax that does not require an
> explicit label - "break <depth>", was considered and dismissed.)
>
> > 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.
> >
>
> Am I right in thinking you would then have :
>
> do {
> switch (...) {
> break outer;
> while outer (...);
>
> You are happy with labelling the loop or switch, but want the label
> at the end, not the start?
>
Almost. I want it at the end and I want it with syntax that can't be
confused with regular goto targets.
> Why not then just use "goto" and put a label at the end of the loop
> or switch? (This is allowed in C23.)
>
Like just about everybody else, I prefer weaker control transfers. They
are not easier to write, but easier to follow by reader.
goto is too powerful - can go everywhere within function. That part is
improved by C2y proposal.
But the labels that goto targets are also too powerful - they can be
reached from everywhere in the function. That part is not just not
improved by proposal, but made worse, because now we not just have a
too powerful label (that we have to name, which is problem by itself,
but lesser evil than break N alternative), but this label creates
another, completely unnecessary, target for goto, that the reader of
code should have in mind.
> >>>> 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.
> >
>
> Okay. There are always changes that we like, changes we dislike, and
> (often the majority) changes to which we are indifferent.
>
> >> 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.
>
> True - but do you /really/ think that is going to be a problem?
>
For me, personally? May be not. Due to (or because of) my age, with
retirement not too distant.
> >> (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
Author: Dan Cross
Date: Sun, 18 Oct 2026 22:18
Date: Sun, 18 Oct 2026 22:18
53 lines
3590 bytes
3590 bytes
In article <11b2pq5$3pvda$7@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>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).
I think colocating it with `do` might create a syntactic
ambiguity. In the case of `for`, `while`, and `select`, there
is a required token following the keyword (the `(`). However,
for a `do`/`while` loop, `do` is followed immediately by a,
`secondary-block` production. In particular, you do not _need_
braces to denote a compound statement after `do`; something like
`do i++; while (i < j);` is perfectly legal in C.
In the N3377 proposal, the new `block-name` is just an
identifier. If it were allowed immediately after the `do`, then
given, `do NAME statement; while(condition);` you can't tell
`NAME` from the name of the loop and a random identifier before
a statement; something like `do LOOP i++; while (i < j);`
appears as though it _would_ be be syntactically valid by N3377
as presently worked, but is the programmer's intent to create a
loop name, or should this just be a syntax error?
By requiring the block-name between a keyword and a
syntactically required `(`, you remove that ambiguity: if there
is an identifier there, then it is a `block-name`; if not, then
the block has no name.
- Dan C.
Re: Taming The Switch-Statement
Author: bart
Date: Sun, 18 Oct 2026 22:20
Date: Sun, 18 Oct 2026 22:20
199 lines
7648 bytes
7648 bytes
On 18/10/2026 20:09, David Brown wrote:
> On 18/10/2026 18:09, bart wrote:
>> 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
>
> Are you suggesting that in your language, "stringtable" could also be
> declared as :
>
> ref ichar [stringtable]
> or
> ][ stringtable ichar ref
> ?
(Warning: longer post than I'd intended.)
I think you're clutching at straws.
[] or [N] means 'array of'
ref means 'pointer to'
proc means 'function returning void'
Then there is an existing standard or user type T.
You use these building blocks to construct types of any complexity. They
are simply chained together, from left to right, ending with T at the right.
If this is part of a variable declaration, then names follow on the
right (but syntaxes vary here).
So you know that ][ makes no sense. Neither does [stringtable] unless
'stringtable' is a valid array-bound expression.
Example, I want a 'pointer to an array of pointer to int':
pointer to array of pointer to int English and CDECL
ref [] ref int My syntax
So 'ref [] ref int'. Now I want to declare 3 such variables of the same
type; no problem:
ref [] ref int x, y, z
Now let's try the same exercise with C:
'pointer to' is *
'array of' is []
But how TF do they go together? Where do I start? It seems I may have to
start from the other end:
int
Now I add the pointer:
int *
I know this far! Now I need to apply [] somewhere, and then another *,
but this can't be it:
int *[]*
OK, here's one I prepared earlier (I didn't need CDECL at all...):
int *(*)[]
Now how about my three variables? Well, here's where the first goes, and
CDECL agrees with me:
int *(*x)[]
But what about y and z? It seems that, in C, the parts of typespec other
than the final T can't be shared. So it has to be this:
int *(*x)[], *(*y)[], *(z)[];
OK, obviously I lied; I had to use CDECL even for a fairly simple type,
because I find C type syntax utterly impossible.
> I suspect that your language also requires the syntactical elements to
> be in the right place.
The difference is that that is literally as simple as writing ABC. This
is the example above:
pointer to array of pointer to int x
ref [] ref int x
A B C D E
The C version is:
int *(* x)[]
D C A E B
Well it's either C A or A C; I don't know, and I don't care as
thankfully I'm not going to deal with this godforsaken language any more.
> I assume that :
>
> [N] ref proc(T) handlertable
>
> and
>
> ref [N] proc(T) handlertable
>
> are different?
Start on the left. One is an array, the other a pointer (to an array of
functions so it's not valid).
> You need to give things in the right order, or use parentheses, to get
> the right "type expression" It's just like any other kind of expression.
So, what do you think the purpose of CDECL is? Since to you, NOTHING
about C type syntax ever appears to be a problem.
Try explaining to me in English what either of those two types are.
You're going to describe them in left-to-right order just like CDECL.
This is also how I would think of them. Then my syntax merely
transcribes that exactly: I can write it as fast as I can type and I
will be 100% sure it corresponds to the type I want.
Try reading a C type spec out loud in the order it is in source code,
complete with parentheses. It just does not work!
> The intention of the declaration syntax in C is that the declaration
> order follows usage.
Which doesn't work either. If I declare P to be a pointer to int, then
it will likely be used like this in an expression:
P
I might also write &P, or *P, or P[i], or *(P + i). With a more complex
type I might also partially dereference or index it.
Now tell me that the declaration of a struct also follows its usage!
> There's a lot of good things to say about
> left-to-right ordering, since that is the order for reading (in English,
> anyway). But it also means the declaration order and usage order are
> different unless your array subscript, pointer dereference and call
> operators are also all left-to-right.
Is that important? People don't seem to have a problem writing
expressions in any language, other than quibbles about post- and pre-fix
operators.
But why is it necessary for the shape of a declaration to have anything
to do with what happens in an expression? I've showed that that can vary
anyway, and with some things (such as structs) it is meaningless.
It simply does not work in C, and just leads to confusion:
int a;
int
*p = &a;
*p = a;
The LHSs of those last two lines are the same, but the RHSs must be
different. One of them is being dereferenced, and the other isn't, even
those both /look/ as though they dereference p.
NO DEREFERENCING is done in the declaration, but it uses dereference
syntax in something that looks exactly like an assignment.
Just admit that the whole concept was a failure. The creators have
already done so.
> My point is not that C's syntax
> is wonderful (I disagree with Kenny here),
He was probably being sarcastic.
> but that it works fine in
> practice,
It works in practice with a lot of trouble, but it is not fine.
> you don't have to write incomprehensible declarations
My threshold is lower than yours. Just mix one * and one [], and I'm
already lost.
That you need to disambiguate using () to distingish *[] from (*)[] is
the wrong approach. That changes between pointer/array and
array/pointer, but mysteriously the * and [] stay in the same order?
Re: Taming The Switch-Statement
Author: Dan Cross
Date: Sun, 18 Oct 2026 22:33
Date: Sun, 18 Oct 2026 22:33
50 lines
3067 bytes
3067 bytes
In article <11b285v$121v2$2@dont-email.me>,
David Brown <david.brown@hesbynett.no> 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.
Tim often makes it sound as though he believes that his opinions
are facts.
>> 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.
No, it was `grep`. The convention originated on Unix, but well
before there was a version of Emacs in widespread use on those
systems; most Unix programmers were using `ed` at the time, and
`vi` was still a few years away; `ctags` was not a thing yet.
Recall that early versions of C defaulted to `int` as a return
type if otherwise unspecified; there was no `void`, so if a
programmer had no intention of returning anything at all, they
would just omit the return type and the `return` statement. The
result was that there were many functions that declared no
return type, and just started with the function at the beginning
of the line; it was natural to use `grep ^name` to look for
those, and it was sufficiently useful that the convention stuck
even as we gained both more powerful editors and more stricter
versions of C.
- Dan C.
Re: Taming The Switch-Statement
Author: Waldek Hebisch
Date: Sun, 18 Oct 2026 23:51
Date: Sun, 18 Oct 2026 23:51
67 lines
4201 bytes
4201 bytes
Dan Cross <cross@spitfire.i.gajendra.net> wrote:
> In article <11b2pq5$3pvda$7@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>>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).
>
> I think colocating it with `do` might create a syntactic
> ambiguity. In the case of `for`, `while`, and `select`, there
> is a required token following the keyword (the `(`). However,
> for a `do`/`while` loop, `do` is followed immediately by a,
> `secondary-block` production. In particular, you do not _need_
> braces to denote a compound statement after `do`; something like
> `do i++; while (i < j);` is perfectly legal in C.
>
> In the N3377 proposal, the new `block-name` is just an
> identifier. If it were allowed immediately after the `do`, then
> given, `do NAME statement; while(condition);` you can't tell
> `NAME` from the name of the loop and a random identifier before
> a statement; something like `do LOOP i++; while (i < j);`
> appears as though it _would_ be be syntactically valid by N3377
> as presently worked, but is the programmer's intent to create a
> loop name, or should this just be a syntax error?
>
> By requiring the block-name between a keyword and a
> syntactically required `(`, you remove that ambiguity: if there
> is an identifier there, then it is a `block-name`; if not, then
> the block has no name.
AFAICS this is worse, both:
do (i++); while (i < j);
and
do LOOP(i++); while (i < j);
are currently legal (assuming that 'LOOP' is a function).
Writing statement with parentheses may look silly, but such code
may be easily produced due to use of macros.
--
Waldek Hebisch
Re: Taming The Switch-Statement
Author: Dan Cross
Date: Sun, 18 Oct 2026 23:56
Date: Sun, 18 Oct 2026 23:56
58 lines
3848 bytes
3848 bytes
In article <11b3gkj$mt2$1@reader2.panix.com>,
Dan Cross <cross@spitfire.i.gajendra.net> wrote:
>In article <11b2pq5$3pvda$7@dont-email.me>,
>Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>>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).
>
>I think colocating it with `do` might create a syntactic
>ambiguity. In the case of `for`, `while`, and `select`, there
>is a required token following the keyword (the `(`). However,
>for a `do`/`while` loop, `do` is followed immediately by a,
>`secondary-block` production. In particular, you do not _need_
>braces to denote a compound statement after `do`; something like
>`do i++; while (i < j);` is perfectly legal in C.
Rather, you _would_ need braces for a _compound statement_, but
a compound statement is not required here.
>In the N3377 proposal, the new `block-name` is just an
>identifier. If it were allowed immediately after the `do`, then
>given, `do NAME statement; while(condition);` you can't tell
>`NAME` from the name of the loop and a random identifier before
>a statement; something like `do LOOP i++; while (i < j);`
>appears as though it _would_ be be syntactically valid by N3377
>as presently worked, but is the programmer's intent to create a
>loop name, or should this just be a syntax error?
>
>By requiring the block-name between a keyword and a
>syntactically required `(`, you remove that ambiguity: if there
>is an identifier there, then it is a `block-name`; if not, then
>the block has no name.
- Dan C.
Re: Taming The Switch-Statement
Author: Dan Cross
Date: Mon, 19 Oct 2026 01:19
Date: Mon, 19 Oct 2026 01:19
193 lines
9189 bytes
9189 bytes
In article <11b0mfv$j5ll$1@dont-email.me>, bart <bc@freeuk.com> 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:
>>>>> 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.
Logical fallacy. I didn't say it did not; I said the languages
you pointed out as being "more productive" than C had other
attributes that make them more productive that you ignored in
your fervor to focus solely on syntax.
I see that you convenient snipped out my comment about C++,
which is the direct counter example. C++ shares much syntax
with C, but also has attributes that make it (generally) more
productive than C; for example, a broad standard library of
generic types and a useful `std::string` type.
Go and Rust both similarly share lots of syntactic elements with
C, yet both are also broadly more "productive".
>> Yes. C's declaration syntax is famously abstruse; film at 11.
>
>And ... that's it? Just accept it? How about doing something about it!
One time, shortly before I deployed to Afghanistan, my (then)
girlfriend and I were sleeping in my apartment in the far
northern reaches of Manhattan when a very (VERY) loud party
started blaring music outside; it was about 1am, and it woke us
both up. "Well, aren't you going to _do_ something about it?"
she asked me, to which I replied, "what, exactly, would you like
me to do?"
I survived that deployment, but the relationship did not.
>I'm angry because to me C was so unusable that I had to create and
>maintain my own products over decades.
"Had" is a strong word; dare I say it...a subjective word.
In fact, there have been all kinds of alternatives for years.
In the earlish 1980s, there was Modula-2, PL/M, Forth, Ada, CLU,
BLISS, and so on. You yourself admit you started from Algol68.
By the late 1980s you had Oberon, decent versions of ML, C++
and Objective-C, etc; by the 1990s, there were more than you
could shake a stick at. Now? Take your pick.
You never "had" to use your own language.
>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.
See my earlier post. That ecosystem is one of the things that
makes C _useful_. /eyeroll
>>> 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.)
No, really; C's declaration syntax was inspired by FORTRAN, and
generations of scientists and engineers have managed that
language just fine. Generations of programmers have handled C's
all right as well.
>> 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!
Then why do you keep bringing your language up, showing snippets
of its syntax, and so on?
>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.
There...have been? And still are?
>Yes, mine has lots of examples of how some alternative features could
>work; so what? I am not selling my language.
Oh good, so you'll stop bringing it up?
>> 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;
Not really, no. I don't do Windows, and I have no desire to
waste my time mucking about with random assembler to get it to
run on something I do have.
But this sort of thing is exactly what I'm talking about: your
language is not useful beyond a userbase of one. You solved a
set of "problems" that you defined for yourself, whether they
were real or not, and now are now sitting here trying to use
that as evidence about a general argument based on false
premises ("there was no alternative! I _had_ to do my own
thing!" "Oh, can I look at it?" "Oh, no; it only works for me,
on my laptop." "....").
>I have destroyed my C-related projects.)
Uh, ok.
>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.
In fact, there have been efforts to do this for _years_. From
heavy weight IDLs and ORBs to wrappers like `swig`, and all of
the languages that used common ABIs (like the VAX Calling
Standard). They all suffer from one of two primary categories
of problems: a) either the mechanisms are too heavyweight or
cumbersome for easy use, or b) the semantics of languages vary
far too much between languages, so even if you can do something
simple like define compatible data types, language A may not be
able to meet all the constraints imposed by language B.
>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).
That's why ABIs matter.
Look at the Vax-11 Procedure Calling and Condition Handling
Standard from VMS 2.0; they simply wrote down what this stuff
meant, and you could call between essentially any language on
that system, whether it was C, Fortran, Bliss, COBOL, or
whatever.
>> 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.
The team that created C was familiar with, and rather liked,
Richard Martin's BCPL. B was created as sort of a chopped down
BCPL that could fit on the PDP-7, a machine with 4KW of 18-bit
core memory, at an access time of ~1.5ms, where most
instructions touch memory twice. Oh, and that machine was
running a multitasking, multiuser operating system and was
self-hosting. And you are seriously comparing your single-user
home PC with 64k of RAM to that environment? I'm not sure you
know what "hardware limitations" are.
As mentioned, C came from B, once they got a PDP-11; it was an
incremental evolution of a language they already had. The type
syntax you find so distasteful was inspired by FORTRAN.
It's so weird to me that you make such absolute pronouncements
about C and the choices that into its design, but are so
ajbectly ignorant of the actual history. Bluntly, you just are
not very well informed about it to make cogent comments.
- Dan C.
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Mon, 19 Oct 2026 01:33
Date: Mon, 19 Oct 2026 01:33
58 lines
3861 bytes
3861 bytes
Michael S <already5chosen@yahoo.com> writes:
> 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.
I see your point, but I disagree.
Let's say we have a language where the end of a loop is marked by a
keyword.
WHILE condition
statement;
statement;
ENDWHILE;
Now we want to add the ability to break out of a specified loop,
possibly from within a nested construct. With your preference:
WHILE condition
statement;
if (error) break OUTER; ENDIF;
statement;
OUTER: ENDWHILE;
Putting the label at the bottom of the loop does show more clearly
the point in the code to which the "break" transfers control. In my
opinion, that's not a good thing.
With the label name at the top:
OUTER:
WHILE condition
statement;
if (error) break OUTER; ENDIF;
statement;
ENDWHILE;
"OUTER" is *the name of the loop*, and the entire loop is the
construct to which "break OUTER" applies.
If the syntax emphasizes the point to which the break jumps, I
don't see much advantage over goto.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Mon, 19 Oct 2026 01:34
Date: Mon, 19 Oct 2026 01:34
14 lines
2350 bytes
2350 bytes
Michael S <already5chosen@yahoo.com> writes:
[...]
> 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.
There is a way to achieve it: "goto".
[...]
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: Lawrence D’Oliveiro
Date: Mon, 19 Oct 2026 01:56
Date: Mon, 19 Oct 2026 01:56
10 lines
1753 bytes
1753 bytes
On Sun, 18 Oct 2026 23:51:25 -0000 (UTC), Waldek Hebisch wrote: > Writing statement with parentheses may look silly, but such code may > be easily produced due to use of macros. Why do you need to distinguish between “statements” and “expressions”, anyway? By the way, the precursor of C, BCPL, allowed statement sequences inside expressions. For some reason this got dropped from C.
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Mon, 19 Oct 2026 02:37
Date: Mon, 19 Oct 2026 02:37
35 lines
2715 bytes
2715 bytes
Lawrence D’Oliveiro <ldo@nz.invalid> writes:
> On Sun, 18 Oct 2026 23:51:25 -0000 (UTC), Waldek Hebisch wrote:
>> Writing statement with parentheses may look silly, but such code may
>> be easily produced due to use of macros.
>
> Why do you need to distinguish between “statements” and “expressions”,
> anyway?
Because C strongly distinguishes between statements and expressions.
If you don't want to make that distinction, you'll need to use a
different language.
(The context was that a suggested change to C would be syntactically
ambiguous.)
> By the way, the precursor of C, BCPL, allowed statement sequences
> inside expressions. For some reason this got dropped from C.
Yes.
There is a proposal to add statement expressions to C, based on
the existing gcc extension. This is not reflected in the latest
C2y draft.
Note that statements and expressions are still distinct. An
expression statement can be formed from an expression by adding
a semicolon. A statement expression (given the extension) can be
formed from a compound statement by adding parentheses.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3643.htm
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: Waldek Hebisch
Date: Mon, 19 Oct 2026 08:46
Date: Mon, 19 Oct 2026 08:46
40 lines
3093 bytes
3093 bytes
bart <bc@freeuk.com> wrote:
> 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.)
You say that you had commercial product, but you are apparently not
aware of basic marketing principles. You do not win in the market
by making easy switch from your product to competitor product. You
may want to make it easy to switch _to_ your product. But you want
to make switching to competing products as hard as possible. Of
course there are constraints on this, in the process you do not want
to deteriorate quality of your product too much and you have finite
development resources.
Judging on this criteria you should admit that C is pretty good:
people wrote translators from various languages to C, but there
seem to be no success story going in opposite direction. C++
managed to take over nontrivial part of market previously occupied
by C, but they did this by embedding largish subset of C and by
massvie pileup of extra features.
--
Waldek Hebisch
Re: Taming The Switch-Statement
Author: David Brown
Date: Mon, 19 Oct 2026 09:16
Date: Mon, 19 Oct 2026 09:16
96 lines
6426 bytes
6426 bytes
On 18/10/2026 21:38, Michael S wrote:
> On Sun, 18 Oct 2026 20:47:13 +0200
> David Brown <david.brown@hesbynett.no> wrote:
>
>> On 18/10/2026 17:16, Michael S wrote:
>>> All I wanted to say is that I prefer label to be located at where
>>> the break goes.
>>
>> In C2y, you /do/ put the label along with the break - you write
>> "break outer;". But you also have to put the label "outer : " at the
>> start of the control structure.
>>
>> If you want to have some kind of "break to outer structure" /without/
>> having a name or label on the structure, then you need some other way
>> to refer to it. I thought you had said before your preference was
>> for something like "break_switch" (ignoring any bike-shedding on the
>> syntax), which would work in the particular case of a switch with
>> nested loop(s). And as I wrote, this was considered and dismissed.
>> (Equally, the other plausible syntax that does not require an
>> explicit label - "break <depth>", was considered and dismissed.)
>>
>>> 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.
>>>
>>
>> Am I right in thinking you would then have :
>>
>> do {
>> switch (...) {
>> break outer;
>> while outer (...);
>>
>> You are happy with labelling the loop or switch, but want the label
>> at the end, not the start?
>>
>
> Almost. I want it at the end and I want it with syntax that can't be
> confused with regular goto targets.
>
I can appreciate wanting a syntax that is distinct from regular labels
for "goto".
(I can also appreciate that others prefer a similarity - they want to be
able to use the same label for "goto", it means less new learning, and
fewer conflicts with things like syntax highlighters. Since I
personally don't expect to use the feature much, and have almost no use
for "goto" or labels today, I am ambivalent here, and prefer to leave
the decision to those with more direct experience. There has been
plenty of discussion on the pros and cons here.)
However, I am curious as to why you see putting the name or label at the
end of the loop or switch as important. A "break <name>" will go to the
end, but a "continue <name>" will go back to the start. Do you see
"break" as more common or more important than "continue" ? Goto labels
are an exception, but the normal rule in C is that names are introduced
before their use.
>> Why not then just use "goto" and put a label at the end of the loop
>> or switch? (This is allowed in C23.)
>>
>
> Like just about everybody else, I prefer weaker control transfers. They
> are not easier to write, but easier to follow by reader.
> goto is too powerful - can go everywhere within function. That part is
> improved by C2y proposal.
(I am not sure that "weak" or "strong" is the right adjective here - I
see "for" and "while" as /stronger/ than "goto" because they provide
more structure and guarantees about the control flow. But I know what
you mean, and agree with you.)
> But the labels that goto targets are also too powerful - they can be
> reached from everywhere in the function. That part is not just not
> improved by proposal, but made worse, because now we not just have a
> too powerful label (that we have to name, which is problem by itself,
> but lesser evil than break N alternative), but this label creates
> another, completely unnecessary, target for goto, that the reader of
> code should have in mind.
Labelled breaks can eliminate a significant use of "goto". (And if
"defer" makes it into C2y and gains popularity - admittedly a big "if" -
that could eliminate the other major use of "goto".) If there is no
"goto" in the function, there is no concern about where it might go.
There is always going to be scope for misunderstanding, no matter what
syntax is used. It is good to pick a syntax that reduces the risk, but
it cannot be eliminated - ultimately, individual programmers are
responsible for writing clear code.
I think your concerns are valid, but I think (or hope) that they are
more pessimistic than realistic.
Re: Taming The Switch-Statement
Author: Waldek Hebisch
Date: Mon, 19 Oct 2026 09:18
Date: Mon, 19 Oct 2026 09:18
26 lines
2207 bytes
2207 bytes
Dan Cross <cross@spitfire.i.gajendra.net> wrote:
> In article <11b0mfv$j5ll$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>
>>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).
>
> That's why ABIs matter.
>
> Look at the Vax-11 Procedure Calling and Condition Handling
> Standard from VMS 2.0; they simply wrote down what this stuff
> meant, and you could call between essentially any language on
> that system, whether it was C, Fortran, Bliss, COBOL, or
> whatever.
That is getting off-topic, but I looked at VMS documentation.
Simple cases are described with a lot of details. But I was
unable to find general case. Say, given array of structs
containing notrivial types like arrays inside. It seems that
for such types it is essentially "whatever language processor
decides to do" and the other end must know the convention.
Which seem to be exactly what happens on other platforms.
--
Waldek Hebisch
Re: Taming The Switch-Statement
Author: David Brown
Date: Mon, 19 Oct 2026 10:26
Date: Mon, 19 Oct 2026 10:26
52 lines
3600 bytes
3600 bytes
On 19/10/2026 00:20, bart wrote: > On 18/10/2026 20:09, David Brown wrote: >> On 18/10/2026 18:09, bart wrote: > >>> 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 >> >> Are you suggesting that in your language, "stringtable" could also be >> declared as : >> >> ref ichar [stringtable] >> or >> ][ stringtable ichar ref >> ? > > (Warning: longer post than I'd intended.) > > I think you're clutching at straws. I am simply mocking your suggestion that "requiring the syntactical elements to be in the right place" is a "problem" unique to C. I'm snipping the irrelevant stuff about your language - I don't know why you bother posting it. I also don't know why you bothered inventing new meaningless combinations of pointers, arrays and functions. > > So, what do you think the purpose of CDECL is? Since to you, NOTHING > about C type syntax ever appears to be a problem. I've never had any use of CDECL - it has no purpose to me. I doubt if many people use it except for extreme artificial examples. > > Just admit that the whole concept was a failure. The creators have > already done so. The early C designers have said that the declaration syntax for C ended up more complex than it could have been, and with hindsight they would have picked a different syntax. Fair enough. But they did not "admit that the whole concept was a failure". Anyone who has used C significantly (like anyone who has used any programming language significantly) has things about the language and syntax that they dislike and think could have been better. But no language has had comparable success to that of C. It is utterly laughable to say that "the whole concept of C's declaration syntax was a failure".
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Mon, 19 Oct 2026 10:50
Date: Mon, 19 Oct 2026 10:50
55 lines
4011 bytes
4011 bytes
David Brown <david.brown@hesbynett.no> writes:
[...]
> I can appreciate wanting a syntax that is distinct from regular labels
> for "goto".
So can I. The first language I used that had this kind of thing
was Ada. In the language's initial design, it was decided that
though goto statements were needed, the labels should stand out:
<<LABEL>>
-- ...
goto LABEL;
Names used for loops have a lighter-weight syntax:
LOOP_NAME:
while condition loop
-- ...
end loop;
I can't think of a better syntax for loop names than "NAME:" (used
by several other languages), but in C that syntax is already
taken for goto labels. The possibility of any ambiguity between
"goto NAME;" and "break NAME;" doesn't bother me enough to want
to invent something new. And I consider the fact that other
languages use the "NAME:" syntax for loop names to be another
point in its favor.
The odd scoping rules for labels don't bother me either. They mean
you can't have two loops or switch statements with the same name in
the same function. I can barely imagine that being inconvenient.
And it's already specified in the latest C2y draft, and implemented in
gcc and clang, which means there's already some inertia against any
major changes. Anything could happen between now and the publication
of the next C standard, but I don't see any need to make significant
changes in this area.
I use Perl's equivalent of named break quite a lot. I found
31 occurrences of "exit NAME" in a collection of Perl scripts
I've written. I'm a little surprised to find that none of these
break out of nested loops; I just like to name loops for clarity.
I even find that having to choose a name for something forces
me to think more clearly about it.
The C2y proposed syntax and semantics for named loops and switch
statements is of course imperfect, but it's reasonably clean
and useful. I see no need to make any significant changes in
this area.
[...]
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: David Brown
Date: Mon, 19 Oct 2026 10:59
Date: Mon, 19 Oct 2026 10:59
64 lines
4794 bytes
4794 bytes
On 19/10/2026 12:50, Keith Thompson wrote: > David Brown <david.brown@hesbynett.no> writes: > [...] >> I can appreciate wanting a syntax that is distinct from regular labels >> for "goto". > > So can I. The first language I used that had this kind of thing > was Ada. In the language's initial design, it was decided that > though goto statements were needed, the labels should stand out: > > <<LABEL>> > -- ... > goto LABEL; > > Names used for loops have a lighter-weight syntax: > > LOOP_NAME: > while condition loop > -- ... > end loop; > > I can't think of a better syntax for loop names than "NAME:" (used > by several other languages), but in C that syntax is already > taken for goto labels. The possibility of any ambiguity between > "goto NAME;" and "break NAME;" doesn't bother me enough to want > to invent something new. And I consider the fact that other > languages use the "NAME:" syntax for loop names to be another > point in its favor. > > The odd scoping rules for labels don't bother me either. They mean > you can't have two loops or switch statements with the same name in > the same function. I can barely imagine that being inconvenient. I can imagine that being a bit inconvenient in some cases, but I think the proposal in N3658 would simply and cleanly fix that. > > And it's already specified in the latest C2y draft, and implemented in > gcc and clang, which means there's already some inertia against any > major changes. Anything could happen between now and the publication > of the next C standard, but I don't see any need to make significant > changes in this area. > > I use Perl's equivalent of named break quite a lot. I found > 31 occurrences of "exit NAME" in a collection of Perl scripts > I've written. I'm a little surprised to find that none of these > break out of nested loops; I just like to name loops for clarity. > I even find that having to choose a name for something forces > me to think more clearly about it. > > The C2y proposed syntax and semantics for named loops and switch > statements is of course imperfect, but it's reasonably clean > and useful. I see no need to make any significant changes in > this area. > There are always going to be disagreements about language features and syntax - even more so when they are added late to a language, rather than part of the initial design. (Maybe if named loops and "defer" were part of the original C, it would never have needed "goto" and labels.) Changes and additions have to be of enough potential benefit, and low enough cost or potential confusion - they don't have to be "perfect" or suit the needs and preferences of everyone.
Re: Taming The Switch-Statement
Author: bart
Date: Mon, 19 Oct 2026 11:47
Date: Mon, 19 Oct 2026 11:47
210 lines
9836 bytes
9836 bytes
On 19/10/2026 02:19, Dan Cross wrote:
> In article <11b0mfv$j5ll$1@dont-email.me>, bart <bc@freeuk.com> wrote:
> I see that you convenient snipped out my comment about C++,
> which is the direct counter example.
I don't want to discuss C++. That language is abominable, other than as
the go-to example of language design going very wrong.
> "Had" is a strong word; dare I say it...a subjective word.
>
> In fact, there have been all kinds of alternatives for years.
> In the earlish 1980s, there was Modula-2, PL/M, Forth, Ada, CLU,
> BLISS, and so on. You yourself admit you started from Algol68.
> By the late 1980s you had Oberon, decent versions of ML, C++
> and Objective-C, etc; by the 1990s, there were more than you
> could shake a stick at. Now? Take your pick.
>
> You never "had" to use your own language.
OK. But they HAD to create C? There were quite a few languages in the
early 70s too: like Pascal, Fortran, PL/I, Coral-66, plus of course BCPL
and B. So why a new one?
Anyway you don't know my circumstances. My homemade machine had
absolutely ZERO software. I literally had to start from binary machine
code, as there was no keyboard at first (more below).
I also never used Algol68; I'd only seen it in a book.
In my job later I was an engineer, not a programmer, and there was no
budget for software such as compilers. But they would anyway have been a
nightmare to install (floppy disk formats were not standard!), and would
been hopelessly slow to use.
The language I ended up creating was perfect for my needs and compiled
more or less instantly.
>> You do know; you just don't want to admit it. (Imagine introducing C
>> declarations into a current language.)
>
> No, really; C's declaration syntax was inspired by FORTRAN, and
> generations of scientists and engineers have managed that
> language just fine.
FORTRAN syntax looked nothing like C! Unless you mean the general
pattern of 'INTEGER A, B' which was shared by half of all languages.
(I spent a year writing FORTRAN on mainframes and minicomputers.)
> Generations of programmers have handled C's
> all right as well.
How many gave up because it was too much? How many still struggle with
it and have to employ those 4 or 5 workarounds which I mention
elsewhere? How much has it affected productivity?
Your statement is meaningless. Maybe some task (in any sphere) takes 17
steps to achieve. People will manage. But then somebody figures out how
to do it in 3 steps; that's better right?
No, according to you: let's stick with 17 steps; people have always
managed, and 10 million people can't be wrong!
> Then why do you keep bringing your language up, showing snippets
> of its syntax, and so on?
Suppose that language didn't exist. I guess then it would be OK to bring
up hypothetical new features and bits of syntax here? People do it all
the time (even Keith did today, of all people).
But if those examples come from an actual, working and proven
implementation, which lend them more weight, then it is not allowed and
the examples then become irrelevant?
I guess it is not playing the game in that case?
>> 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.
>
> There...have been? And still are?
In that case, why has C itself been so heavily used, in OSes, drivers,
and endless libraries, rather than one those which you suggest I adopt?
I needed a language that worked at a lower level, could access hardware,
had inline assembly, had a weak type system that allowed all sorts of
underhand methods /to get things done/.
And that is exactly what I created in the early 80s, along with, as it
turned out, very fast implementations.
C would also have been a good fit, and presumably why it was so popular
for actual systems programming tasks.
So WHAT C does is good; HOW it does it is bad - in my opinion, and lots
of others. The difference is others have be work with it, while I had
the choice of persevering with mine.
Still, this is C in 2026:
#include <stdint.h>
uint8_t a, b, c;
This is mine in 1981 and in 2026
byte a, b, c
>> Yes, mine has lots of examples of how some alternative features could
>> work; so what? I am not selling my language.
>
> Oh good, so you'll stop bringing it up?
Forget the actual language: why is not possible to concentrate on some
specific feature or approach, and consider that in isolation and without
bias?
It either has merit or it hasn't. In any case, when I posted a link to
that document about my language, people (especially JP) said it was
derivative with nothing new.
So that's OK then? Just pretend some feature has been used in some more
famous language.
> Not really, no. I don't do Windows,
OK. I mentioned it because some people don't believe my language exists.
I have posted links to working versions over the years, but I usually
found that a waste of time, as now. (I still had to prepare and test the
version I'd have linked to.)
> But this sort of thing is exactly what I'm talking about: your
> language is not useful beyond a userbase of one.
That is 100% not true. It would be useful to anyone working on Windows
or even Linux. But it was never intended as a product used by other
people. As I said I'm not selling it, and would not want to support it.
> You solved a
> set of "problems" that you defined for yourself, whether they
> were real or not,
The scope of my language seems to overlap with the scope of C.
and now are now sitting here trying to use
> that as evidence about a general argument based on false
> premises ("there was no alternative! I _had_ to do my own
> thing!"
I gave you my circumstances above. What would /you/ have done?
> That's why ABIs matter.
You're confusing APIs and ABIs.
ABIs are a matter for compilers. Translating APIs into a set of bindings
for another language is someone else's job.
>> So you can't use limited resources as an excuse for its questionable
>> choices. Actually some choices actually made it harder to parse.
>
> The team that created C was familiar with, and rather liked,
> Richard Martin's BCPL. B was created as sort of a chopped down
> BCPL that could fit on the PDP-7, a machine with 4KW of 18-bit
> core memory, at an access time of ~1.5ms, where most
> instructions touch memory twice. Oh, and that machine was
> running a multitasking, multiuser operating system and was
> self-hosting. And you are seriously comparing your single-user
> home PC with 64k of RAM to that environment? I'm not sure you
> know what "hardware limitations" are.
My first machine actually had 256 bytes of RAM, no input, no output, and
unreliable cassette tape storage made with shift registers and counters.
I had ZERO existing software. No money. I didn't work in academia, nor
in a company, had no people to help. There weren't lots of other,
existing machines and terminals lying around to prepare programs on.
Yes the hardware was more compact and cheaper compared with 1970
(although SRAM still cost £24,000,000 per GB -- in 1981 money!) but I
was lacking everything else.
In any case, we're talking about C. Was a PDP 11/20 less powerful than a
2.5MHz Z80 with the 32KB I ended up with? I've no idea. But the crude
language I created FROM NOTHING still looked like this:
int a, b, c
println a + b
> As mentioned, C came from B, once they got a PDP-11; it was an
> incremental evolution of a language they already had. The type
> syntax you find so distasteful was inspired by FORTRAN.
Please give an example of FORTRAN that looks like C.
> It's so weird to me that you make such absolute pronouncements
> about C and the choices that into its design, but are so
> ajbectly ignorant of the actual history. Bluntly, you just are
> not very well informed about it to make cogent comments.
How does knowing the history in such detail help? If a feature stinks,
it stinks.
See my post yesterday about the impact choosing a prefix dereference op
instead of postfix made on the language. It was probably even more
far-reaching than stated.
And yet Pascal was right there!
That choice had nothing to with limited hardware; it was just the wrong one.
Re: Taming The Switch-Statement
Author: Dan Cross
Date: Mon, 19 Oct 2026 12:00
Date: Mon, 19 Oct 2026 12:00
52 lines
3474 bytes
3474 bytes
In article <11b4n9g$4fik$2@paganini.bofh.team>,
Waldek Hebisch <antispam@fricas.org> wrote:
>Dan Cross <cross@spitfire.i.gajendra.net> wrote:
>> In article <11b0mfv$j5ll$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>>
>>>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).
>>
>> That's why ABIs matter.
>>
>> Look at the Vax-11 Procedure Calling and Condition Handling
>> Standard from VMS 2.0; they simply wrote down what this stuff
>> meant, and you could call between essentially any language on
>> that system, whether it was C, Fortran, Bliss, COBOL, or
>> whatever.
>
>That is getting off-topic, but I looked at VMS documentation.
>Simple cases are described with a lot of details. But I was
>unable to find general case. Say, given array of structs
>containing notrivial types like arrays inside. It seems that
>for such types it is essentially "whatever language processor
>decides to do" and the other end must know the convention.
>Which seem to be exactly what happens on other platforms.
I imagine in that case one would use an array descriptor to
describe the array, and then a more specific descriptor (or set
of) to describe the structure of each element of the array.
In any event, the thing they did that's relevant here is
describing the properties of the basic types (what the VAX-11
run-time library reference manual calls, "atomic types", which
should not be confused with what we now call atomic types, that
have specific properties on multi-CPU systems; the VMS 2.0 docs
just meant the primitive data types understood by the VAX
hardware; bytes words, long/quad/octowords, and so on).
The point I was trying to make, and how it's relevant to C, is
that this is an early-ish example of what we now would think of
as an ABI, and it made (say) inter-language procedures calls
tractable. I don't know quite how to articulate it in a way
that won't kick over the language-lawyer hornet's nest, but
informally, the C standard doesn't mandate any particular ABI,
and indeed, tries to steer clear of such things to the extent
that it can. Bart complains about the need to deal with the "C
API", but really, he's referring to ABI issues ("is `char`
signed or not?" The ISO C doesn't say, but within each ABI, we
know.
- Dan C.
Re: Taming The Switch-Statement
Author: David Brown
Date: Mon, 19 Oct 2026 12:08
Date: Mon, 19 Oct 2026 12:08
61 lines
4019 bytes
4019 bytes
On 19/10/2026 13:47, bart wrote: > On 19/10/2026 02:19, Dan Cross wrote: >> In article <11b0mfv$j5ll$1@dont-email.me>, bart <bc@freeuk.com> wrote: > >> I see that you convenient snipped out my comment about C++, >> which is the direct counter example. > > I don't want to discuss C++. That language is abominable, other than as > the go-to example of language design going very wrong. And yet it is another /massively/ successful language. Perhaps you are correct that C and C++ are terrible designs - but that would mean "good" and "bad" language design has nothing much to do with how successful a language is, or how many people manage to use the language to write good, working, useful software. Mind you, we have no examples of languages that you consider "good" language design, other than your own languages. > >> "Had" is a strong word; dare I say it...a subjective word. >> >> In fact, there have been all kinds of alternatives for years. >> In the earlish 1980s, there was Modula-2, PL/M, Forth, Ada, CLU, >> BLISS, and so on. You yourself admit you started from Algol68. >> By the late 1980s you had Oberon, decent versions of ML, C++ >> and Objective-C, etc; by the 1990s, there were more than you >> could shake a stick at. Now? Take your pick. >> >> You never "had" to use your own language. > > OK. But they HAD to create C? There were quite a few languages in the > early 70s too: like Pascal, Fortran, PL/I, Coral-66, plus of course BCPL > and B. So why a new one? Check off "whataboutism" on the logical fallacy bingo card ! > >> Generations of programmers have handled C's >> all right as well. > > How many gave up because it was too much? How many still struggle with > it and have to employ those 4 or 5 workarounds which I mention > elsewhere? How much has it affected productivity? I have never heard of anyone giving up C because of the declaration syntax. Have you? Once you have removed pathological examples, I have not seen anyone but C newbies have trouble with real-world C declarations - and having trouble when you are new to a language is perfectly normal for all languages. And by "workarounds", do you mean language features for working with types? I have heard people complain about C's declaration syntax, and heard people say it is weird, or ugly, or counter-intuitive - but not that it actually causes real productivity problems, real bugs, or chases people away from the language. Any point you may have had has been long lost in your wild exaggerations.
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Mon, 19 Oct 2026 13:16
Date: Mon, 19 Oct 2026 13:16
34 lines
3105 bytes
3105 bytes
On 2026-10-18 21:09, David Brown wrote: > On 18/10/2026 18:09, bart wrote: >> [...] [ declaration syntax ] (I just want to comment on a [not unimportant] detail...) > > You need to give things in the right order, or use parentheses, to get > the right "type expression". It's just like any other kind of expression. > > The intention of the declaration syntax in C is that the declaration > order follows usage. [...] I think the first part is downplaying that languages typically indeed make a distinction between parenthesized expressions and declarations. Quite some other languages [not from the C-heritage] that I used all did not need to introduce "expression"-grouping for _declarations_ in the first place given their more consistent ways to declare entities. The second part is, as I had understood C's history, the idea behind how it got defined; needless to say that I think that was a bad idea. But that's what we've got! If they had dropped that requirement/idea the declaration syntax could have become "better" (more consistent, less cryptic, less convoluted, clearer). Now, after half a century, we just have to live with that, and folks who have "problems" with it should better not touch this language (or maybe not doing programming at all). The somewhat tragic aspect is that the "declaration follows use" idea was (IIRC) intended to _simplify_ the understanding of its concepts and use of the language; the consequences were seemingly not valued correctly. Janis
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Mon, 19 Oct 2026 13:44
Date: Mon, 19 Oct 2026 13:44
65 lines
3832 bytes
3832 bytes
On 2026-10-18 18:32, Michael S wrote: > On Sun, 18 Oct 2026 18:11:18 +0200 > Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: >> 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? > > IMHO, no. Okay, if you think so. > >> Simpler for compilers? > > 100% no. I've read that would be a, albeit small, existing factor (when resolving ambiguities or some such; but I don't recall details). Anyway, I just want to mention some existing purported arguments, so I take your word as granted. > >> More consistent if all other, especially standard >> operators known from daily use are used in prefix-form (-5, +42, >> !false, ~bitset) in expressions? > > Unary * is more similar in function to postfix operators like [] and () > than to those you mentioned. I don't know how you come to that opinion. Personally I've learned the concepts in abstract, non-language-specific forms as 'deref'; "deref p" not "p deref"; to me the former looks more natural, but we can agree that this may be just our personal preferences). (A less low-level language will ideally anyway abstract from any explicit dereferentiation, but since we're speaking about "C" I'm not expanding further on that.) > >> >> I don't recall to have used any language with infix-expressions >> that would have their monadic operators defined in postfix form. > > I am a Bear of Very Little Brain, and long words Bother Me. (If that quote is important for your argument, please explain.) > > By chance, did you never use Pascal? Oh, yes, how could I forget that! (I stand corrected.) - I suppose it's because I considered that more an "accessor" than an operator (like the array or struct selectors); that's also why it's often not listed in Pascal's operator precedence tables. - So thanks for the reminder. Janis
Re: Taming The Switch-Statement
Author: David Brown
Date: Mon, 19 Oct 2026 13:46
Date: Mon, 19 Oct 2026 13:46
62 lines
4819 bytes
4819 bytes
On 19/10/2026 15:16, Janis Papanagnou wrote: > On 2026-10-18 21:09, David Brown wrote: >> On 18/10/2026 18:09, bart wrote: >>> [...] > [ declaration syntax ] > > (I just want to comment on a [not unimportant] detail...) > >> >> You need to give things in the right order, or use parentheses, to get >> the right "type expression". It's just like any other kind of >> expression. >> >> The intention of the declaration syntax in C is that the declaration >> order follows usage. [...] > > I think the first part is downplaying that languages typically indeed > make a distinction between parenthesized expressions and declarations. > Quite some other languages [not from the C-heritage] that I used all > did not need to introduce "expression"-grouping for _declarations_ in > the first place given their more consistent ways to declare entities. > > The second part is, as I had understood C's history, the idea behind > how it got defined; needless to say that I think that was a bad idea. > But that's what we've got! If they had dropped that requirement/idea > the declaration syntax could have become "better" (more consistent, > less cryptic, less convoluted, clearer). Now, after half a century, > we just have to live with that, and folks who have "problems" with it > should better not touch this language (or maybe not doing programming > at all). The somewhat tragic aspect is that the "declaration follows > use" idea was (IIRC) intended to _simplify_ the understanding of its > concepts and use of the language; the consequences were seemingly not > valued correctly. > There are a number of things that I don't particularly like about C's declaration syntax, or where I think it would have been better if it were different. But the "inside-to-outside" ordering is not one of them. That is not because I think it is better or clearer than left-to-right ordering, but because when I compare to, say, Pascal, it's not a big issue for me. Far bigger are : 1. People put too much into a single type declaration, rather than building types out of logical parts with a purpose and a name. They don't do it as much as Bart likes to pretend, but some people do it too much for my liking. The language doesn't force you to do that - it's programmer style. IMHO there is never a reason for a "pointer to an array of function pointers taking int and returning void" - no matter what syntax is used. Give a name to the function pointer type that reflects the usage (/not/ a name that reflects the definition), and build up from there. 2. Being able to declare variables and functions with different types in the same declaration. Very occasionally, I find it convenient to declare more than one variable at once - "int a, b, c;". It is rare in my code - generally it is one variable with an initialiser (and perhaps a comment) at a time. But it is - IMHO - a bad thing that you can write "int a, xs[20], *p, (*f)(void);" in one declaration. Both of these are overcome by simply not writing code that way. Obviously that is easy to achieve in my own code, but other people may use a different style.
Re: Taming The Switch-Statement
Author: bart
Date: Mon, 19 Oct 2026 14:00
Date: Mon, 19 Oct 2026 14:00
79 lines
4842 bytes
4842 bytes
On 19/10/2026 09:46, Waldek Hebisch wrote: > bart <bc@freeuk.com> wrote: >> 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.) > > You say that you had commercial product, but you are apparently not > aware of basic marketing principles. You do not win in the market > by making easy switch from your product to competitor product. You > may want to make it easy to switch _to_ your product. But you want > to make switching to competing products as hard as possible. Of > course there are constraints on this, in the process you do not want > to deteriorate quality of your product too much and you have finite > development resources. > > Judging on this criteria you should admit that C is pretty good: > people wrote translators from various languages to C, but there > seem to be no success story going in opposite direction. There are lots of reasons why not. C is popular as a compiler target because it is lower level than the source language. It has a weak type system which is easy to circumvent. It has 'goto'! (Many languages don't) There are well established, ubiquitous optimising compilers for it. Now, what would be the reasons for going the other way? There aren't any! (Well, some languages may have a feature to translate C programs into their syntax so that development can proceed in the new language. But the start point here is not C code being used for development, with some other HLL as an intermediate form.) So for that purpose, C is probably the most practical of current HLLs. Even if it is still not ideal and there are features which are awkward to express as C. C's UBs also get in the way. I've tried several times myself both with high-level and low-level generated C. (However, as a target language, I recently tried my own for that purpose, and it worked perfectly! Some features such as out-of-order definitions made it easier than C. Of course, my product does not have optimising compilers and very limited targets, due to not having an army of 1000s taking care of that as happens with C. But it shows that the creating such a suitable language design is not hard.) > C++ > managed to take over nontrivial part of market previously occupied > by C, but they did this by embedding largish subset of C and by > massvie pileup of extra features. So why IS C still around given that C++ compiler can build C programs, more or less?
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Mon, 19 Oct 2026 14:03
Date: Mon, 19 Oct 2026 14:03
64 lines
4355 bytes
4355 bytes
On 2026-10-19 15:46, David Brown wrote: > On 19/10/2026 15:16, Janis Papanagnou wrote: >> [...] >> > There are a number of things that I don't particularly like about C's > declaration syntax, or where I think it would have been better if it > were different. But the "inside-to-outside" ordering is not one of > them. That is not because I think it is better or clearer than left-to- > right ordering, but because when I compare to, say, Pascal, it's not a > big issue for me. Far bigger are : > > 1. People put too much into a single type declaration, rather than > building types out of logical parts with a purpose and a name. Yes, that can be regularly observed, and not only in case of the declaration but generally; with known building blocks you can construct arbitrary complex expressions incrementally, so it might not appear as a problem at the time one writes it. But then parsing complex expressions - say, if that code is from another person or source - it gets difficult. (Topic reminds me Regexp expressions.) But also program composition in general is sometimes following an incremental growing process. Structuring is the key. > They > don't do it as much as Bart likes to pretend, but some people do it too > much for my liking. The language doesn't force you to do that - it's > programmer style. IMHO there is never a reason for a "pointer to an > array of function pointers taking int and returning void" - no matter > what syntax is used. Give a name to the function pointer type that > reflects the usage (/not/ a name that reflects the definition), and > build up from there. I fully agree. Where I obviously have a different valuation is that I saw in other languages' contexts that there's less issues with this topic. > > 2. Being able to declare variables and functions with different types in > the same declaration. Very occasionally, I find it convenient to > declare more than one variable at once - "int a, b, c;". It is rare in > my code - generally it is one variable with an initialiser (and perhaps > a comment) at a time. Absolutely the same for me. > But it is - IMHO - a bad thing that you can write > "int a, xs[20], *p, (*f)(void);" in one declaration. I agree. - But as opposed to other posters that's no serious problem; "if it hurts, just don't do it". > > Both of these are overcome by simply not writing code that way. (I should have read your post to the end before my previous statement.) > Obviously that is easy to achieve in my own code, but other people may > use a different style. And that's why companies instantiate coding standards. Janis
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Mon, 19 Oct 2026 14:15
Date: Mon, 19 Oct 2026 14:15
57 lines
3799 bytes
3799 bytes
On 2026-10-19 00:18, Dan Cross wrote:
> In article <11b2pq5$3pvda$7@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>> 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. [...]
>
> I think colocating it with `do` might create a syntactic
> ambiguity. In the case of `for`, `while`, and `select`, there
> is a required token following the keyword (the `(`). However,
> for a `do`/`while` loop, `do` is followed immediately by a,
> `secondary-block` production.
Good point!
> In particular, you do not _need_
> braces to denote a compound statement after `do`; something like
> `do i++; while (i < j);` is perfectly legal in C.
Yes.
>
> In the N3377 proposal, the new `block-name` is just an
> identifier. If it were allowed immediately after the `do`, then
> given, `do NAME statement; while(condition);` you can't tell
> `NAME` from the name of the loop and a random identifier before
> a statement; something like `do LOOP i++; while (i < j);`
> appears as though it _would_ be be syntactically valid by N3377
> as presently worked, but is the programmer's intent to create a
> loop name, or should this just be a syntax error?
>
> By requiring the block-name between a keyword and a
> syntactically required `(`, you remove that ambiguity: if there
> is an identifier there, then it is a `block-name`; if not, then
> the block has no name.
Thanks for your elaborations.
Janis
Re: Taming The Switch-Statement
Author: Dan Cross
Date: Mon, 19 Oct 2026 14:35
Date: Mon, 19 Oct 2026 14:35
19 lines
1790 bytes
1790 bytes
In article <11b4smj$1vt4q$1@kst.eternal-september.org>, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >The odd scoping rules for labels don't bother me either. They mean >you can't have two loops or switch statements with the same name in >the same function. I can barely imagine that being inconvenient. An issue is that one might generate such a named loop with a macro. I can imagine that being useful for `XIMPL` type constructs, but C's macros are unusually weak, and C doesn't have something like `(GENSYM)` in Lisp, so you've got to plumb the loop name through the macro invocation: mildly annoying, but not too bad. Then again, if a programmer is abusing macros like that to generate named loops multiple times in the same function, then perhaps the program needs a re-think, ximpl or no. - Dan C.
Re: Taming The Switch-Statement
Author: Tim Rentsch
Date: Mon, 19 Oct 2026 15:47
Date: Mon, 19 Oct 2026 15:47
59 lines
4278 bytes
4278 bytes
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> 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.)
Anyone who thinks my statement "the second ("for NAME (;;)") is
unquestionably better" was meant as a statement of fact rather
than a statement of opinion is an idiot.
I think most people can see that I am careful in my writing, and
also that I make an effort to differentiate statements of opinion,
statements of belief, and statements of fact. My remark above is
no exception to that practice.
For the benefit of any other people who may have not seen the
distinction here, please remember this: any statement that uses
the word "better", when made without any reference to some sort of
objective metric, is inherently a subjective statement. Any
subjective statement (that does not fall into the category of
being a statement of belief) is a statement of opinion. It's easy
to see this simply by a process of elimination, because subjective
statements are not facts, and vice versa.
>> 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.) :-)
My confidence in the collective wisdom of the ISO C committee has
declined in recent years, and sadly for more than just the last
few years. So learning that they have settled (even if that might
change in the future) on the "label: for(...)" approach is
disappointing, but not surprising.
Re: Taming The Switch-Statement
Author: Richard Harnden
Date: Mon, 19 Oct 2026 15:55
Date: Mon, 19 Oct 2026 15:55
9 lines
1856 bytes
1856 bytes
On 19/10/2026 15:00, bart wrote: > > So why IS C still around given that C++ compiler can build C programs, > more or less? Because it's typically less. I see C and C++ as very different.
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Mon, 19 Oct 2026 16:28
Date: Mon, 19 Oct 2026 16:28
36 lines
3391 bytes
3391 bytes
[ with big snips of lots of irrelevant stuff ] On 2026-10-19 17:47, Tim Rentsch wrote: >> On 2026-10-18 12:48, David Brown wrote: >>> >>> The C standards committee collectively reached an agreement counter >>> to Tim's thoughts, so clearly his preferred variant is /not/ >>> unquestionably better. > > My confidence in the collective wisdom of the ISO C committee has > declined in recent years, and sadly for more than just the last > few years. So learning that they have settled (even if that might > change in the future) on the "label: for(...)" approach is > disappointing, but not surprising. I understand the disappointment when something evolves differently, where own opinions or own "educated or acquired wisdom" diverges. (Such expressed disappointment is observable with some other poster here as well.) Opinions are fine, arguments are better. The arguments (meanwhile) exchanged here let me come to another conclusion than you, though, concerning the competence or rather the thoughtfulness of the involved committee members. And, to come back to the primary topic; the "problems" adding such features to "C" (with all perceived sub-optimality of every option) is primarily based on how it had been designed back then. (It's not so much a problem of the specific "collective [committee] wisdom". IMHO and YMMV.) I don't think it makes sense to continue discussions on that level. Janis
Re: Taming The Switch-Statement
Author: David Brown
Date: Mon, 19 Oct 2026 16:31
Date: Mon, 19 Oct 2026 16:31
34 lines
2673 bytes
2673 bytes
On 19/10/2026 16:35, Dan Cross wrote: > In article <11b4smj$1vt4q$1@kst.eternal-september.org>, > Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >> The odd scoping rules for labels don't bother me either. They mean >> you can't have two loops or switch statements with the same name in >> the same function. I can barely imagine that being inconvenient. > > An issue is that one might generate such a named loop with a > macro. I can imagine that being useful for `XIMPL` type > constructs, but C's macros are unusually weak, and C doesn't > have something like `(GENSYM)` in Lisp, so you've got to plumb > the loop name through the macro invocation: mildly annoying, but > not too bad. Hopefully the N3658 fix for that will be in C2y. <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3658.htm> That will also let people - for better or worse - write things like: #define For Loop_label: for #define While Loop_label: while #define Switch Switch_label #define Break_Loop break Loop_label #define Break_Switch break Switch_label > > Then again, if a programmer is abusing macros like that to > generate named loops multiple times in the same function, > then perhaps the program needs a re-think, ximpl or no. > > - Dan C. >
Re: Taming The Switch-Statement
Author: Dan Cross
Date: Mon, 19 Oct 2026 17:22
Date: Mon, 19 Oct 2026 17:22
249 lines
11002 bytes
11002 bytes
In article <11b500f$216c4$1@dont-email.me>, bart <bc@freeuk.com> wrote: >On 19/10/2026 02:19, Dan Cross wrote: >> I see that you convenient snipped out my comment about C++, >> which is the direct counter example. > >I don't want to discuss C++. That language is abominable, other than as >the go-to example of language design going very wrong. Oh. You don't _want_ to; I see. So you want to make statements about the relative "productivity" of languages but ignore the most prominent counter example to your argument because you don't _want_ to discuss C++. >> "Had" is a strong word; dare I say it...a subjective word. >> >> In fact, there have been all kinds of alternatives for years. >> In the earlish 1980s, there was Modula-2, PL/M, Forth, Ada, CLU, >> BLISS, and so on. You yourself admit you started from Algol68. >> By the late 1980s you had Oberon, decent versions of ML, C++ >> and Objective-C, etc; by the 1990s, there were more than you >> could shake a stick at. Now? Take your pick. >> >> You never "had" to use your own language. > >OK. But they HAD to create C? Doesn't matter. They did. You weren't there; you don't know why they made the decisions they made, whether they gave this or that serious consideration and dismissed it, or were unaware of one thing or another, what constraints they were operating under, etc. It is _so easy_ to sit here and throw stones at people toiling away in the 1960's because they made decisions you don't like. But, bluntly, you haven't put in the work to have an opinion: you are ignorant of the history, and actively resist even simple things like reading the standard to back up your assertions; when you're shown to be incorrect, you double down or (yes) move the goalposts by making some other statement. You came up with your toy language and compiler in the 80s; more than a decade after C. It's cute that you felt you _had_ to do that, but you were in a completely different context than the 1127 folks at Bell Labs who created C. >There were quite a few languages in the >early 70s too: like Pascal, Fortran, PL/I, Coral-66, plus of course BCPL >and B. So why a new one? B _was_ a new language. Pascal as a useful language beyond pedagogy postdates C. Pretty much the rest of this is discussed in DMR's C history paper, which I'm willing to bet you haven't bothered to read. >Anyway you don't know my circumstances. My homemade machine had >absolutely ZERO software. I literally had to start from binary machine >code, as there was no keyboard at first (more below). Next you'll tell us you went to the beach and picked up sand so you could smelt it and create your own silicon wafers, right? You described its capabilities. It was vastly more capable than a PDP-7, and it had only one user: you. >I also never used Algol68; I'd only seen it in a book. You said yourself you modeled your language on Algol68; whether you had used it or not is irrelevant. >In my job later I was an engineer, not a programmer, and there was no >budget for software such as compilers. But they would anyway have been a >nightmare to install (floppy disk formats were not standard!), and would >been hopelessly slow to use. > >The language I ended up creating was perfect for my needs and compiled >more or less instantly. You said you could not use a compiler and then literally described using a compiler. >>> You do know; you just don't want to admit it. (Imagine introducing C >>> declarations into a current language.) >> >> No, really; C's declaration syntax was inspired by FORTRAN, and >> generations of scientists and engineers have managed that >> language just fine. > >FORTRAN syntax looked nothing like C! Unless you mean the general >pattern of 'INTEGER A, B' which was shared by half of all languages. That was literally the thing you said you address with left-to-right syntax, and that anyone who proposed such would be laughed at. Now it's fine, just not in C. Because C is bad. Or something. >(I spent a year writing FORTRAN on mainframes and minicomputers.) I'm sure no one else here has done that. (*rolls eyes*) >> Generations of programmers have handled C's >> all right as well. > >How many gave up because it was too much? How many still struggle with >it and have to employ those 4 or 5 workarounds which I mention >elsewhere? How much has it affected productivity? > >Your statement is meaningless. Maybe some task (in any sphere) takes 17 >steps to achieve. People will manage. But then somebody figures out how >to do it in 3 steps; that's better right? Maybe, maybe not. There may well be other considerations that factor into that decision. >No, according to you: let's stick with 17 steps; people have always >managed, and 10 million people can't be wrong! So by this metric, it's cool if a pilot just jumps into an airliner, turns it on, and takes off? The rest of the pre-flight checklist is just busywork, amirite? >> Then why do you keep bringing your language up, showing snippets >> of its syntax, and so on? > >Suppose that language didn't exist. I guess then it would be OK to bring >up hypothetical new features and bits of syntax here? People do it all >the time (even Keith did today, of all people). > >But if those examples come from an actual, working and proven >implementation, which lend them more weight, then it is not allowed and >the examples then become irrelevant? If you want to discuss C on its merits, then discuss C. Unfortunately for you that would probably mean you'd have to actually read the relevant documentation. Do you _really_ think that the people who post here regularly are not aware that, say, other variable declaration syntaxes exist that are less messy than C's? No, seriously, don't give me some other example from your language, answer that question honestly: do you _really_ believe that no one here understands that fact, or just outright disbelieves it? >I guess it is not playing the game in that case? >>> 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. >> >> There...have been? And still are? > >In that case, why has C itself been so heavily used, in OSes, drivers, >and endless libraries, rather than one those which you suggest I adopt? I can think of any number of reasons: legacy, compatibility, tool availability, in some cases just personal preference. For any one of these, I'm sure that someone has already told you sometime in the last six months. My repeating them is unlikely to have any effect. >I needed a language that worked at a lower level, could access hardware, >had inline assembly, had a weak type system that allowed all sorts of >underhand methods /to get things done/. >[snip same stuff over again] No one cares. >[snip] >I gave you my circumstances above. What would /you/ have done? Probably not spent years seething about how the rest of the world is wrong for making decisions I would not have. >[snip] >> That's why ABIs matter. > >You're confusing APIs and ABIs. > >ABIs are a matter for compilers. Translating APIs into a set of bindings >for another language is someone else's job. You really don't understand how multilangauge environments work, do you? Maybe have a look at an ABI document at some point. >[snip sob story about walking uphill both ways in the snow] >But the crude >language I created FROM NOTHING still looked like this: > > int a, b, c > println a + b Ok. Don't really care. >> As mentioned, C came from B, once they got a PDP-11; it was an >> incremental evolution of a language they already had. The type >> syntax you find so distasteful was inspired by FORTRAN. > >Please give an example of FORTRAN that looks like C. Why? What would that show? If you'd get over yourself for ten minutes and read the HOPL paper on C, you may see this: |Fortran influenced the syntax of declarations: B declarations |begin with a specifier like `auto` or `static`, followed by a |list of names, and C not only followed this style but |ornamented it by placing its type keywords at the start of |declarations. (https://www.nokia.com/bell-labs/about/dennis-m-ritchie/chist.html) >> It's so weird to me that you make such absolute pronouncements >> about C and the choices that into its design, but are so >> ajbectly ignorant of the actual history. Bluntly, you just are >> not very well informed about it to make cogent comments. > >How does knowing the history in such detail help? If a feature stinks, >it stinks. Much of your ranting amounts to, "how could anyone have possibly thought this was a good idea?" Perhaps if you looked into the history a bit, you may become enlightened as to why anybody possibly thought it was a good idea. >See my post yesterday about the impact choosing a prefix dereference op >instead of postfix made on the language. It was probably even more >far-reaching than stated. > >And yet Pascal was right there! Amazingly, ALGOL W used syntax much closer to C's, despite being the immediate predecessor of Pascal. >That choice had nothing to with limited hardware; it was just the wrong one. One final quote from HOPL: |Although we entertained occasional thoughts about implementing |one of the major languages of the time like Fortran, PL/I, or |Algol 68, such a project seemed hopelessly large for our |resources: much simpler and smaller tools were called for. All |these languages influenced our work, but it was more fun to do |things on our own. So, they were aware of all the languages you've cited as influences. And yet they decided to do things differently. Perhaps they had their reasons. They are not (in the case of Ken) and were not (sadly, in the case of Dennis) idiiots or fools. - Dan C.
Re: Taming The Switch-Statement
Author: bart
Date: Mon, 19 Oct 2026 19:34
Date: Mon, 19 Oct 2026 19:34
252 lines
11987 bytes
11987 bytes
On 19/10/2026 18:22, Dan Cross wrote: > In article <11b500f$216c4$1@dont-email.me>, bart <bc@freeuk.com> wrote: >> On 19/10/2026 02:19, Dan Cross wrote: >>> I see that you convenient snipped out my comment about C++, >>> which is the direct counter example. >> >> I don't want to discuss C++. That language is abominable, other than as >> the go-to example of language design going very wrong. > > Oh. You don't _want_ to; I see. So you want to make statements > about the relative "productivity" of languages but ignore the > most prominent counter example to your argument because you > don't _want_ to discuss C++. > >>> "Had" is a strong word; dare I say it...a subjective word. >>> >>> In fact, there have been all kinds of alternatives for years. >>> In the earlish 1980s, there was Modula-2, PL/M, Forth, Ada, CLU, >>> BLISS, and so on. You yourself admit you started from Algol68. >>> By the late 1980s you had Oberon, decent versions of ML, C++ >>> and Objective-C, etc; by the 1990s, there were more than you >>> could shake a stick at. Now? Take your pick. >>> >>> You never "had" to use your own language. >> >> OK. But they HAD to create C? > > Doesn't matter. They did. You weren't there; you don't know > why they made the decisions they made, whether they gave this or > that serious consideration and dismissed it, or were unaware of > one thing or another, what constraints they were operating > under, etc. > > It is _so easy_ to sit here and throw stones at people toiling > away in the 1960's because they made decisions you don't like. > But, bluntly, you haven't put in the work to have an opinion: > you are ignorant of the history, and actively resist even simple > things like reading the standard to back up your assertions; > when you're shown to be incorrect, you double down or (yes) move > the goalposts by making some other statement. > > You came up with your toy language and compiler in the 80s; more > than a decade after C. It's cute that you felt you _had_ to do > that, but you were in a completely different context than the > 1127 folks at Bell Labs who created C. > >> There were quite a few languages in the >> early 70s too: like Pascal, Fortran, PL/I, Coral-66, plus of course BCPL >> and B. So why a new one? > > B _was_ a new language. Pascal as a useful language beyond > pedagogy postdates C. Pretty much the rest of this is discussed > in DMR's C history paper, which I'm willing to bet you haven't > bothered to read. > >> Anyway you don't know my circumstances. My homemade machine had >> absolutely ZERO software. I literally had to start from binary machine >> code, as there was no keyboard at first (more below). > > Next you'll tell us you went to the beach and picked up sand so > you could smelt it and create your own silicon wafers, right? > > You described its capabilities. It was vastly more capable than > a PDP-7, and it had only one user: you. > >> I also never used Algol68; I'd only seen it in a book. > > You said yourself you modeled your language on Algol68; whether > you had used it or not is irrelevant. > >> In my job later I was an engineer, not a programmer, and there was no >> budget for software such as compilers. But they would anyway have been a >> nightmare to install (floppy disk formats were not standard!), and would >> been hopelessly slow to use. >> >> The language I ended up creating was perfect for my needs and compiled >> more or less instantly. > > You said you could not use a compiler and then literally > described using a compiler. > >>>> You do know; you just don't want to admit it. (Imagine introducing C >>>> declarations into a current language.) >>> >>> No, really; C's declaration syntax was inspired by FORTRAN, and >>> generations of scientists and engineers have managed that >>> language just fine. >> >> FORTRAN syntax looked nothing like C! Unless you mean the general >> pattern of 'INTEGER A, B' which was shared by half of all languages. > > That was literally the thing you said you address with > left-to-right syntax, and that anyone who proposed such would be > laughed at. Now it's fine, just not in C. Because C is bad. > Or something. > >> (I spent a year writing FORTRAN on mainframes and minicomputers.) > > I'm sure no one else here has done that. (*rolls eyes*) > >>> Generations of programmers have handled C's >>> all right as well. >> >> How many gave up because it was too much? How many still struggle with >> it and have to employ those 4 or 5 workarounds which I mention >> elsewhere? How much has it affected productivity? >> >> Your statement is meaningless. Maybe some task (in any sphere) takes 17 >> steps to achieve. People will manage. But then somebody figures out how >> to do it in 3 steps; that's better right? > > Maybe, maybe not. There may well be other considerations that > factor into that decision. > >> No, according to you: let's stick with 17 steps; people have always >> managed, and 10 million people can't be wrong! > > So by this metric, it's cool if a pilot just jumps into an > airliner, turns it on, and takes off? The rest of the > pre-flight checklist is just busywork, amirite? > >>> Then why do you keep bringing your language up, showing snippets >>> of its syntax, and so on? >> >> Suppose that language didn't exist. I guess then it would be OK to bring >> up hypothetical new features and bits of syntax here? People do it all >> the time (even Keith did today, of all people). >> >> But if those examples come from an actual, working and proven >> implementation, which lend them more weight, then it is not allowed and >> the examples then become irrelevant? > > If you want to discuss C on its merits, then discuss C. > Unfortunately for you that would probably mean you'd have to > actually read the relevant documentation. > > Do you _really_ think that the people who post here regularly > are not aware that, say, other variable declaration syntaxes > exist that are less messy than C's? No, seriously, don't give > me some other example from your language, answer that question > honestly: do you _really_ believe that no one here understands > that fact, or just outright disbelieves it? > >> I guess it is not playing the game in that case? >>>> 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. >>> >>> There...have been? And still are? >> >> In that case, why has C itself been so heavily used, in OSes, drivers, >> and endless libraries, rather than one those which you suggest I adopt? > > I can think of any number of reasons: legacy, compatibility, > tool availability, in some cases just personal preference. For > any one of these, I'm sure that someone has already told you > sometime in the last six months. My repeating them is unlikely > to have any effect. > >> I needed a language that worked at a lower level, could access hardware, >> had inline assembly, had a weak type system that allowed all sorts of >> underhand methods /to get things done/. >> [snip same stuff over again] > > No one cares. > >> [snip] >> I gave you my circumstances above. What would /you/ have done? > > Probably not spent years seething about how the rest of the > world is wrong for making decisions I would not have. > >> [snip] >>> That's why ABIs matter. >> >> You're confusing APIs and ABIs. >> >> ABIs are a matter for compilers. Translating APIs into a set of bindings >> for another language is someone else's job. > > You really don't understand how multilangauge environments work, > do you? Maybe have a look at an ABI document at some point. > >> [snip sob story about walking uphill both ways in the snow] >> But the crude >> language I created FROM NOTHING still looked like this: >> >> int a, b, c >> println a + b > > Ok. Don't really care. > >>> As mentioned, C came from B, once they got a PDP-11; it was an >>> incremental evolution of a language they already had. The type >>> syntax you find so distasteful was inspired by FORTRAN. >> >> Please give an example of FORTRAN that looks like C. > > Why? What would that show? > > If you'd get over yourself for ten minutes and read the HOPL > paper on C, you may see this: > > |Fortran influenced the syntax of declarations: B declarations > |begin with a specifier like `auto` or `static`, followed by a > |list of names, and C not only followed this style but > |ornamented it by placing its type keywords at the start of > |declarations. > (https://www.nokia.com/bell-labs/about/dennis-m-ritchie/chist.html) > >>> It's so weird to me that you make such absolute pronouncements >>> about C and the choices that into its design, but are so >>> ajbectly ignorant of the actual history. Bluntly, you just are >>> not very well informed about it to make cogent comments. >> >> How does knowing the history in such detail help? If a feature stinks, >> it stinks. > > Much of your ranting amounts to, "how could anyone have possibly > thought this was a good idea?" Perhaps if you looked into the > history a bit, you may become enlightened as to why anybody > possibly thought it was a good idea. > >> See my post yesterday about the impact choosing a prefix dereference op >> instead of postfix made on the language. It was probably even more >> far-reaching than stated. >> >> And yet Pascal was right there! > > Amazingly, ALGOL W used syntax much closer to C's, despite being > the immediate predecessor of Pascal. > >> That choice had nothing to with limited hardware; it was just the wrong one. > > One final quote from HOPL: > |Although we entertained occasional thoughts about implementing > |one of the major languages of the time like Fortran, PL/I, or > |Algol 68, such a project seemed hopelessly large for our > |resources: much simpler and smaller tools were called for. All > |these languages influenced our work, but it was more fun to do > |things on our own. > > So, they were aware of all the languages you've cited as > influences. And yet they decided to do things differently. > > Perhaps they had their reasons. They are not (in the case of > Ken) and were not (sadly, in the case of Dennis) idiiots or > fools. If you're going to shit over everything I say, ignore points and keep changing the subject, then OK you win, I lose. Satisfied?
Re: Taming The Switch-Statement
Author: Michael S
Date: Mon, 19 Oct 2026 19:35
Date: Mon, 19 Oct 2026 19:35
23 lines
2516 bytes
2516 bytes
On Mon, 19 Oct 2026 15:44:40 +0200 Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: > On 2026-10-18 18:32, Michael S wrote: > > On Sun, 18 Oct 2026 18:11:18 +0200 > > Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: > >> > >> I don't recall to have used any language with infix-expressions > >> that would have their monadic operators defined in postfix form. > > > > I am a Bear of Very Little Brain, and long words Bother Me. > > (If that quote is important for your argument, please explain.) > Translation: 1. I have no idea what unary * has to do with infix-expressions 2. I don't appriciate use of the term "infix-expression" instead of more common (in context of description of C and similar languages) term 'binary operators'. 3. I don't know what "monadic operators defined in postfix form" means and have no plans to look for the meaning
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Mon, 19 Oct 2026 21:27
Date: Mon, 19 Oct 2026 21:27
70 lines
4620 bytes
4620 bytes
On 2026-10-19 21:35, Michael S wrote: > On Mon, 19 Oct 2026 15:44:40 +0200 > Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: > >> On 2026-10-18 18:32, Michael S wrote: >>> On Sun, 18 Oct 2026 18:11:18 +0200 >>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: >>>> >>>> I don't recall to have used any language with infix-expressions >>>> that would have their monadic operators defined in postfix form. >>> >>> I am a Bear of Very Little Brain, and long words Bother Me. >> >> (If that quote is important for your argument, please explain.) >> > > Translation: > 1. I have no idea what unary * has to do with infix-expressions > 2. I don't appriciate use of the term "infix-expression" instead of more > common (in context of description of C and similar languages) term > 'binary operators'. > 3. I don't know what "monadic operators defined in postfix form" means > and have no plans to look for the meaning > I'm sorry, these are (AFAICT) common terms, and I thought obvious. So let me explain and amend with more text and examples... Point 1. - I gave the hint that in languages that support RPN (= Reverse Polish Notation) things like monadic postfix operators (= having just _one_ argument applied _after_ the operator) are the natural way of writing expressions. Less so in languages, which are the majority since decades, that support expressions with infix operators (= the operator arguments left and right of the operator). Point 2. - A "binary operator" may be the '*' in the expressions a * b typical infix notation (with parenthesis for precedence) a b * RPN * a b PN (Polish Notation) A "binary operator" is something different from an "infix expression" (the first one of the three; the others are RPN and PN examples). That's why I took the appropriate term to explain what I intended to explain. Point 3. - "monadic" (see point 1). Applying to postfix form is best explained on another example; assume RPN a - monadic (unary) minus (on one argument) a b - dyadic (binary) minus (difference of two arguments) Hope the terms are clear now. Now consider our original case, e.g. a * *b ... multiply and dereference a - -b ... subtract and negate as soon as we parse the second operator we know its kind. With postfix operators we'd have (assuming same semantics but with postfix operators) a * b * ... now what is the second '*' at that point of parsing? a - b - ... we don't expect that second '-' to be a negation. The compilers can handle every variant. For the users it's different; usually they seem to prefer unary operators to be prefixed (YMMV). The question (concerning "C") was; would it have been "better" (in any respect) if the dereferencing operator would have been defined in "C" as postfix operator (as you seem to prefer). Janis
Re: Taming The Switch-Statement
Author: bart
Date: Mon, 19 Oct 2026 21:28
Date: Mon, 19 Oct 2026 21:28
83 lines
5515 bytes
5515 bytes
On 19/10/2026 14:46, David Brown wrote:
> On 19/10/2026 15:16, Janis Papanagnou wrote:
>> On 2026-10-18 21:09, David Brown wrote:
>>> On 18/10/2026 18:09, bart wrote:
>>>> [...]
>> [ declaration syntax ]
>>
>> (I just want to comment on a [not unimportant] detail...)
>>
>>>
>>> You need to give things in the right order, or use parentheses, to
>>> get the right "type expression". It's just like any other kind of
>>> expression.
>>>
>>> The intention of the declaration syntax in C is that the declaration
>>> order follows usage. [...]
>>
>> I think the first part is downplaying that languages typically indeed
>> make a distinction between parenthesized expressions and declarations.
>> Quite some other languages [not from the C-heritage] that I used all
>> did not need to introduce "expression"-grouping for _declarations_ in
>> the first place given their more consistent ways to declare entities.
>>
>> The second part is, as I had understood C's history, the idea behind
>> how it got defined; needless to say that I think that was a bad idea.
>> But that's what we've got! If they had dropped that requirement/idea
>> the declaration syntax could have become "better" (more consistent,
>> less cryptic, less convoluted, clearer). Now, after half a century,
>> we just have to live with that, and folks who have "problems" with it
>> should better not touch this language (or maybe not doing programming
>> at all). The somewhat tragic aspect is that the "declaration follows
>> use" idea was (IIRC) intended to _simplify_ the understanding of its
>> concepts and use of the language; the consequences were seemingly not
>> valued correctly.
>>
> There are a number of things that I don't particularly like about C's
> declaration syntax, or where I think it would have been better if it
> were different. But the "inside-to-outside" ordering is not one of
> them. That is not because I think it is better or clearer than left-to-
> right ordering, but because when I compare to, say, Pascal, it's not a
> big issue for me. Far bigger are :
>
> 1. People put too much into a single type declaration, rather than
> building types out of logical parts with a purpose and a name. They
> don't do it as much as Bart likes to pretend, but some people do it too
> much for my liking. The language doesn't force you to do that - it's
> programmer style. IMHO there is never a reason for a "pointer to an
> array of function pointers taking int and returning void" - no matter
> what syntax is used.
Then you have a peculiar and restricted coding style.
(Funny that when I suggest that nested loop breaks are uncommon,
everyone says I'm wrong! Some even write 200-line made-up examples to
prove their point.)
These are two actual function pointer arrays from my projects (not C):
[]ref proc hosthandlers = ...
[pclnames.len]ref proc(pcl) px_handlertable
There is no reason to abstract away that function pointer type.
You probably do so in C /because/ the type involves * () and [] but have
somehow persuaded yourself that it just better that way.
Note that 'pcl' in my example /is/ a typedef; here it makes sense as it
is used in 100s of places. This function pointer occurs in only one place.
(The C version looks like: 'void (*name[N]))T)'. I used a tool and
transcribed it, then I double-checked and found I'd written '(*name)[N]'
not '(*name[N])'; I wouldn't have noticed.)
BTW what name would be given to such a function pointer type? There is
nothing obvious other than 'funcptr', but suppose there is more than one
in scope?
Something else strikes me about breaking up a complex type-decl sequence
into a chain of typedefs: if you take that list of typedefs, and rotate
it 90 degrees c/w, you have something that resembles the LTR representation!
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Mon, 19 Oct 2026 21:29
Date: Mon, 19 Oct 2026 21:29
12 lines
2081 bytes
2081 bytes
Darn typo... On 2026-10-19 23:27, Janis Papanagnou wrote: > Point 1. - I gave the hint that in languages that support RPN > (= Reverse Polish Notation) things like monadic postfix operators > (= having just _one_ argument applied _after_ the operator) are the (= having just _one_ argument and operator applied _after_ the argument) > Janis >
Re: Taming The Switch-Statement
Author: Michael S
Date: Mon, 19 Oct 2026 21:57
Date: Mon, 19 Oct 2026 21:57
93 lines
5532 bytes
5532 bytes
On Mon, 19 Oct 2026 23:27:03 +0200 Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: > On 2026-10-19 21:35, Michael S wrote: > > On Mon, 19 Oct 2026 15:44:40 +0200 > > Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: > > > >> On 2026-10-18 18:32, Michael S wrote: > >>> On Sun, 18 Oct 2026 18:11:18 +0200 > >>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: > >>>> > >>>> I don't recall to have used any language with infix-expressions > >>>> that would have their monadic operators defined in postfix form. > >>>> > >>> > >>> I am a Bear of Very Little Brain, and long words Bother Me. > >> > >> (If that quote is important for your argument, please explain.) > >> > > > > Translation: > > 1. I have no idea what unary * has to do with infix-expressions > > 2. I don't appriciate use of the term "infix-expression" instead of > > more common (in context of description of C and similar languages) > > term 'binary operators'. > > 3. I don't know what "monadic operators defined in postfix form" > > means and have no plans to look for the meaning > > > > I'm sorry, these are (AFAICT) common terms, and I thought obvious. > So let me explain and amend with more text and examples... > > Point 1. - I gave the hint that in languages that support RPN > (= Reverse Polish Notation) things like monadic postfix operators > (= having just _one_ argument applied _after_ the operator) are the > natural way of writing expressions. Less so in languages, which are > the majority since decades, that support expressions with infix > operators (= the operator arguments left and right of the operator). > > Point 2. - A "binary operator" may be the '*' in the expressions > a * b typical infix notation (with parenthesis for precedence) > a b * RPN > * a b PN (Polish Notation) > > A "binary operator" is something different from an "infix expression" > (the first one of the three; the others are RPN and PN examples). > That's why I took the appropriate term to explain what I intended to > explain. > O.k. > Point 3. - "monadic" (see point 1). Applying to postfix form is best > explained on another example; assume RPN > a - monadic (unary) minus (on one argument) > a b - dyadic (binary) minus (difference of two arguments) > > Hope the terms are clear now. Now consider our original case, e.g. > > a * *b ... multiply and dereference > a - -b ... subtract and negate > > as soon as we parse the second operator we know its kind. With postfix > operators we'd have (assuming same semantics but with postfix > operators) > > a * b * ... now what is the second '*' at that point of parsing? If C was as strongly typed from the beginning as it ended up in the 2nd half of the 70s then it would make sense to use postfix . (dot) instead of prefix * as dereference operator. Unfortunately, in early stage of development C was almost untyped, so something like that was out of question. > a - b - ... we don't expect that second '-' to be a negation. > > The compilers can handle every variant. For the users it's different; > usually they seem to prefer unary operators to be prefixed (YMMV). > > The question (concerning "C") was; would it have been "better" (in any > respect) if the dereferencing operator would have been defined in "C" > as postfix operator (as you seem to prefer). > > Janis > It would be certainly better in the context of type declarators. By now mixing postfix with prefix is their most confusing part. I have no strong opinion about advantages and disadvantages of postfix in context of use of * in expressions, but suspect that in this context the postfix will slightly reduce the need for parenthesis.
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Mon, 19 Oct 2026 22:28
Date: Mon, 19 Oct 2026 22:28
33 lines
3333 bytes
3333 bytes
David Brown <david.brown@hesbynett.no> writes:
> On 19/10/2026 12:50, Keith Thompson wrote:
[...]
>> The odd scoping rules for labels don't bother me either. They mean
>> you can't have two loops or switch statements with the same name in
>> the same function. I can barely imagine that being inconvenient.
>
> I can imagine that being a bit inconvenient in some cases, but I think
> the proposal in N3658 would simply and cleanly fix that.
[...]
*If* the fact that labels (which are now also loop/switch names)
follow strange scope rules is a real problem, N3658 is probably
the best practical solution. I'm slightly uncomfortable with the
idea of an entity's scope depending on how it's used, not just how
it's defined. I think it introduces a complication to the language
without much real benefit.
But cleaner solutions are impractical.
IMHO the only really clean solution would be to make labels and
loop/switch names distinct, keep the existing scoping rules for
labels, and use more normal scoping rules for loop/switch names.
And if the "while NAME (...)" proposal were accepted, that's probably
how it should work. (But I prefer having the name as a prefix of the
loop or switch statement.)
If N3658 were adopted, it wouldn't bother me much. I just don't
think it's necessary.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Mon, 19 Oct 2026 22:35
Date: Mon, 19 Oct 2026 22:35
59 lines
4113 bytes
4113 bytes
On 2026-10-19 19:22, Dan Cross wrote: > In article <11b500f$216c4$1@dont-email.me>, bart <bc@freeuk.com> wrote: [...] >> I also never used Algol68; I'd only seen it in a book. > > You said yourself you modeled your language on Algol68; whether > you had used it or not is irrelevant. It may be worth the observation we could make here in the flood of bart's posts; most (if not all) features or ideas he seems to have adopted only on a lexical or syntactical level. Given what he gave as examples I have strong doubts that this should be attributed to Algol 68 in its "whole glory". - Syntactical inspiration; maybe. - More than that? - I'd be astonished. [...] > > One final quote from HOPL: > |Although we entertained occasional thoughts about implementing > |one of the major languages of the time like Fortran, PL/I, or > |Algol 68, such a project seemed hopelessly large for our > |resources: much simpler and smaller tools were called for. All > |these languages influenced our work, but it was more fun to do > |things on our own. > > So, they were aware of all the languages you've cited as > influences. And yet they decided to do things differently. Somewhere in a (meanwhile historic; 1990's?) document I read about someone (D.R.?) say that the influence of Algol 68 would be hardly seen in practice (or some such). - It's generally hard to tell if someone adopted concepts from some another specific language or read the language description to just dismiss all their ideas. ;-) In case of "C" and Algol 68, while I indeed see a couple adopted things, they are so rare, lacking the semantic context, or have been realized in a very stripped down variant, that it's hard to speak about being (in a more substantial way) "influenced" by it. To not stress my brain unnecessarily here's what a search suggests: Type Composition, Unions and Casts, Syntax and Operators, and Type Names & Structure. (I could add a few more, but I'd keep it terse.) Type Compositions: fine, but also no rocket science back then. Unions: a completely different concept in "C". Casts: hardly necessary in Algol 68 (primarily used for references). Syntax: beyond block structure, a completely different thing in "C". Operators: Not comparable in many respects. Type Names: 'bool', 'string', 'complex', etc., in original "C"? No. So I agree with the mentioned paper that it's hard to find this Algol 68 inspiration in "C"; and certainly not as a characterizing property of the language. With knowledge and a sharp eye you just find some (often only faint) traces as remains (that might as well have had another origin in some cases as we may infer from the list). Janis > [...]
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Mon, 19 Oct 2026 22:48
Date: Mon, 19 Oct 2026 22:48
43 lines
3534 bytes
3534 bytes
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> On 2026-10-18 21:09, David Brown wrote:
>> On 18/10/2026 18:09, bart wrote:
>>> [...]
> [ declaration syntax ]
>
> (I just want to comment on a [not unimportant] detail...)
>
>> You need to give things in the right order, or use parentheses, to
>> get the right "type expression". It's just like any other kind of
>> expression.
>> The intention of the declaration syntax in C is that the declaration
>> order follows usage. [...]
>
> I think the first part is downplaying that languages typically indeed
> make a distinction between parenthesized expressions and declarations.
> Quite some other languages [not from the C-heritage] that I used all
> did not need to introduce "expression"-grouping for _declarations_ in
> the first place given their more consistent ways to declare entities.
Just one quibble. C's declaration syntax *is* consistent. Its
rules are rigorously specified by the standard, particularly by
the grammar.
Many of us (myself included) don't particularly like it, but that
doesn't mean it's inconsistent.
My own take on all this is that having declaration syntax follow usage
was a very clever idea, where "clever" is not necessarily a compliment.
It was IMHO unsuccessful in the sense that it can lead to confusing
and overly complicated declarations. (Other languages don't have tools
corresponding to cdecl for much the same reason that Spanish-speaking
countries don't have spelling bees.) But it was extraordinarily
successful in the sense that, even if you think it was a bad idea,
it wasn't bad enough to keep C from becoming one of the most popular
programming languages.
(I wonder if keeping the declaration-follows-use principle while
making "*" a postfix operator might have improved things.)
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Mon, 19 Oct 2026 22:55
Date: Mon, 19 Oct 2026 22:55
26 lines
2723 bytes
2723 bytes
On 2026-10-19 23:57, Michael S wrote: > On Mon, 19 Oct 2026 23:27:03 +0200 > Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: > [...] > > If C was as strongly typed from the beginning as it ended up in the 2nd > half of the 70s then it would make sense to use postfix . (dot) instead > of prefix * as dereference operator. Well, in "C" we have (for pointers) at least "p->v" as shortcut of "(*p).v" which is good to have! But that '->' is a dyadic operator and makes (for this specific case) the deref operator unnecessary. We still need it for other purposes, like the often cited "*a++ = *b++". I don't see how the situation would have been different in the 1970's, though. But nevermind. (Other languages might not even impose the differentiation and just have "p.v" and "s.v" for both, access of components referenced by pointer or direct struct access. Yet other languages do any 'deref' implicitly.) Janis > [...]
Re: Taming The Switch-Statement
Author: bart
Date: Mon, 19 Oct 2026 23:04
Date: Mon, 19 Oct 2026 23:04
25 lines
2416 bytes
2416 bytes
On 19/10/2026 23:35, Janis Papanagnou wrote: > On 2026-10-19 19:22, Dan Cross wrote: >> In article <11b500f$216c4$1@dont-email.me>, bart <bc@freeuk.com> wrote: > [...] >>> I also never used Algol68; I'd only seen it in a book. >> >> You said yourself you modeled your language on Algol68; whether >> you had used it or not is irrelevant. > > It may be worth the observation we could make here in the flood of > bart's posts; most (if not all) features or ideas he seems to have > adopted only on a lexical or syntactical level. Given what he gave > as examples I have strong doubts that this should be attributed to > Algol 68 in its "whole glory". - Syntactical inspiration; maybe. - > More than that? - I'd be astonished. Syntax was part-influenced by Algol 60 (DEC), Algol 68, Pascal, Fortran and Ada. It was also case-insensitive (most of them). And expression-based (Algol 68). Type system and semantics were mine and befitted a low level systems language running on and for very low-end hardware.
Re: Taming The Switch-Statement
Author: Keith Thompson
Date: Mon, 19 Oct 2026 23:11
Date: Mon, 19 Oct 2026 23:11
82 lines
5543 bytes
5543 bytes
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>> 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.)
>
> Anyone who thinks my statement "the second ("for NAME (;;)") is
> unquestionably better" was meant as a statement of fact rather
> than a statement of opinion is an idiot.
"Better" is an opinion, and if you had just said that I wouldn't have
replied.
If you're saying that "unquestionably better" is merely an opinion,
I now accept that you meant it that way, but that's not the way I
interpreted it. It implies, not merely that something is better,
but that nobody could possibly question that it's better. I suggest
you write more clearly rather than insulting your readers, perhaps
by choosing a word other than "unquesionably" to denote emphasis.
When I asked you to explain, you responded by giving me a detailed
homework assignment as a prerequisite to answering my question.
Perhaps you weren't serious about that, but I couldn't tell.
To be clear, I am no longer asking you to explain what you meant by
"unquestionably better".
> I think most people can see that I am careful in my writing, and
> also that I make an effort to differentiate statements of opinion,
> statements of belief, and statements of fact. My remark above is
> no exception to that practice.
Apparently you didn't *intend* it to be an exception to that practice.
> For the benefit of any other people who may have not seen the
> distinction here, please remember this: any statement that uses
> the word "better", when made without any reference to some sort of
> objective metric, is inherently a subjective statement. Any
> subjective statement (that does not fall into the category of
> being a statement of belief) is a statement of opinion. It's easy
> to see this simply by a process of elimination, because subjective
> statements are not facts, and vice versa.
<sarcasm>Thank you for explaining that to us.</sarcasm>
You used the phrase "unquestionably better". I questioned that. If
your problem with my response was that you were merely expressing
an opinion, you could have just said that rather than wasting our
time by bloviating about the difference between opinions and facts.
[...]
> My confidence in the collective wisdom of the ISO C committee has
> declined in recent years, and sadly for more than just the last
> few years. So learning that they have settled (even if that might
> change in the future) on the "label: for(...)" approach is
> disappointing, but not surprising.
I acknowledge your opinion. I certainly do not share it.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Taming The Switch-Statement
Author: Janis Papanagnou
Date: Mon, 19 Oct 2026 23:18
Date: Mon, 19 Oct 2026 23:18
72 lines
4736 bytes
4736 bytes
On 2026-10-20 00:48, Keith Thompson wrote: > Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: >> On 2026-10-18 21:09, David Brown wrote: >>> On 18/10/2026 18:09, bart wrote: >>>> [...] >> [ declaration syntax ] >> >> (I just want to comment on a [not unimportant] detail...) >> >>> You need to give things in the right order, or use parentheses, to >>> get the right "type expression". It's just like any other kind of >>> expression. >>> The intention of the declaration syntax in C is that the declaration >>> order follows usage. [...] >> >> I think the first part is downplaying that languages typically indeed >> make a distinction between parenthesized expressions and declarations. >> Quite some other languages [not from the C-heritage] that I used all >> did not need to introduce "expression"-grouping for _declarations_ in >> the first place given their more consistent ways to declare entities. > > Just one quibble. C's declaration syntax *is* consistent. Its > rules are rigorously specified by the standard, particularly by > the grammar. Yes, sure. It's well defined and all that. - What I tried to express by that is that the building rules are not... - coherent, consistent? Well, I think on that level speaking about "inconsistency" is fine. But okay. I think we all know what we have with C's declaration syntax. (And we all, but maybe one, can live with it.) > > Many of us (myself included) don't particularly like it, but that > doesn't mean it's inconsistent. > > My own take on all this is that having declaration syntax follow usage > was a very clever idea, where "clever" is not necessarily a compliment. Well, to return the quibble, clever is a compliment (while "clever" in quotes is obviously not). :-) I don't consider it to have been a clever idea. (No quotes.) But I had mentioned that elsethread already before, and it's IMO not worth a dispute. > It was IMHO unsuccessful in the sense that it can lead to confusing > and overly complicated declarations. And that's the essence of the criticism, I think. > (Other languages don't have tools > corresponding to cdecl for much the same reason that Spanish-speaking > countries don't have spelling bees.) But it was extraordinarily > successful in the sense that, even if you think it was a bad idea, > it wasn't bad enough to keep C from becoming one of the most popular > programming languages. Undoubtedly. (It wasn't bad enough.) - Now imagine if it were better! Would have all folks using - what-do-I-know, say, Java - then have settled with "C"? - I'm just kidding. > > (I wonder if keeping the declaration-follows-use principle while > making "*" a postfix operator might have improved things.) I'm confused about the recent emphasis of such a change; it very much sounds to me like: "we have a problem lets try fixing it by changing something else [instead of addressing the problem]"; both are useless thoughts. (Yes, I understand that you think about it academically.) Janis
Page 6 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