• does an expression in a logical statement need parenthesis for proper evaluation?

    From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Thu Nov 5 17:42:54 2026
    From Newsgroup: comp.lang.c

    Hi,

    Does an expression in a logical statement need parenthesis for proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    goto L463;
    }

    Thanks,
    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c++,comp.lang.c on Thu Nov 5 16:33:18 2026
    From Newsgroup: comp.lang.c

    Lynn McGuire <lynnmcguire5@gmail.com> writes:
    Does an expression in a logical statement need parenthesis for proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    goto L463;
    }

    No, but redundant parentheses are mostly harmless.

    The outer parentheses are of course part of the syntax of the "if"
    statement, but the operator precedences are unambiguous. `j1 * i1 < 1`
    can never be evaluated as `j1 * (i1 < 1)`.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 01:40:48 2026
    From Newsgroup: comp.lang.c

    On 2026-11-06 00:42, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for proper evaluation in C and/or C++?

    No, below (assuming i1 and j1 are arithmetic types (and not used
    as "camouflaged" booleans) there's no parenthesis necessary.

    The necessity of parentheses depends on the operators used. In
    "C" the multiplication has higher precedence than the comparison.

    I suggest to get an Operator Precedence Table from the Net and
    inspect it until you got familiar with the operator precedences.
    Most precedences are anyway sensibly defined as you'd expect it.
    But be careful when using bit-expressions with '&', '|', and '^'
    especially if used together with the comparison operators.

    Janis


    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a goto L463;
    }

    Thanks,
    Lynn


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.c++,comp.lang.c on Fri Nov 6 00:44:30 2026
    From Newsgroup: comp.lang.c

    On Thu, 5 Nov 2026 17:42:54 -0600, Lynn McGuire wrote:

    Does an expression in a logical statement need parenthesis for proper evaluation in C and/or C++?

    No <https://en.cppreference.com/c/language/operator_precedence>.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From James Kuyper@jameskuyper@alumni.caltech.edu to comp.lang.c++,comp.lang.c on Thu Nov 5 19:52:31 2026
    From Newsgroup: comp.lang.c

    On 2026-11-05 18:42, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    goto L463;
    }
    No general statement can be made about that issue. It depends entirely
    upon the expression. The syntax rules of C (and the slightly different
    grammar rules of C++) specify what order the parts of the logical
    expression get evaluated in. If that happens to be the order that you
    want, no parentheses are needed. Otherwise, one or more parentheses
    might solve the problem.

    For the most part, the grammar was fairly well designed for the purpose
    of reducing the number of parentheses needed. For example, all
    arithmetic operators have higher precedence than the comparison
    operators, which in turn have higher priority than the logical
    operators. That is why the parentheses you added above are unnecessary.
    For historical reasons, bitwise or (|) and bitwise and (&) are
    exceptions. Unfortunately, correcting that mistake would break backwards compatibility, which is a fairly high priority with both the C and C++ committees.

    It never hurts to insert parentheses to specify precisely the order of evaluation that you want - except insofar as other people reading your
    code who know that a given set of parentheses are unnecessary might
    guess that you don't. If you don't want them to do that, take the time
    to learn the grammar rules.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Thu Nov 5 19:07:46 2026
    From Newsgroup: comp.lang.c

    On 11/5/2026 5:42 PM, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a goto L463;
    }

    Thanks,
    Lynn

    Thank you all very much. BTW, there were parenthesis in the old Fortran
    code but F2C stripped them out. I put them back in for my comfort as I
    see them.

    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.c++,comp.lang.c on Fri Nov 6 01:12:15 2026
    From Newsgroup: comp.lang.c

    On Thu, 5 Nov 2026 19:52:31 -0500, James Kuyper wrote:

    For historical reasons, bitwise or (|) and bitwise and (&) are
    exceptions. Unfortunately, correcting that mistake would break
    backwards compatibility ...

    The only real issue is that bitwise ops have lower priority than
    comparisons, when they should be higher. If they were higher, then an expression like

    (bitval & mask) == desired_value

    wouldnrCOt need parentheses.

    Realistically, can anyone offer *any* real-world C code that
    uses an expression that would be parenthesized like

    a & (b == c)

    ? The reason why I ask is that Python makes exactly this change to the
    operator precedences, and I have yet to come across anybody complain
    that they converted some expression from C to Python, and it came up
    with the wrong answer because of this issue.

    In fact, I only discovered for myself that Python did the precedence differently because I mistakenly wrote some code without the usual C-precedence-compatible parentheses

    bitval & mask == desired_value

    and got the right answer anyway. ;)
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c++,comp.lang.c on Thu Nov 5 21:35:02 2026
    From Newsgroup: comp.lang.c

    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]
    Otherwise, one or more parentheses
    might solve the problem.

    Technically correct (the best kind of correct), but *two* or more
    parentheses are even better.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Tim Rentsch@tr.17687@z991.linuxsc.com to comp.lang.c on Thu Nov 5 21:40:45 2026
    From Newsgroup: comp.lang.c

    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]

    Otherwise, one or more parentheses
    might solve the problem.

    Technically correct (the best kind of correct), but *two* or more
    parentheses are even better.

    Wouldn't it be better still to say one or more pairs of
    parentheses?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Fri Nov 6 08:49:15 2026
    From Newsgroup: comp.lang.c

    On 06/11/2026 02:07, Lynn McGuire wrote:
    On 11/5/2026 5:42 PM, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for proper
    evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }

    Thanks,
    Lynn

    Thank you all very much.-a BTW, there were parenthesis in the old Fortran code but F2C stripped them out.-a I put them back in for my comfort as I
    see them.


    Since you are generating the C++ code automatically, there should not be
    a problem adding the parentheses. Generated code that contains "goto
    L463" is clearly not intended for humans anyway (at least, not without a
    good deal of effort).

    There is a proportion of programmers who think it is somehow blasphemy
    to use more parentheses in an expression than strictly necessary. That
    type of programmer will also disapprove of the extra braces around the
    "goto" in your example.

    There is a proportion of programmers who think you should /always/ use parentheses to show the precedence of operators.

    Most programmers, I think, are in the middle. Parentheses here can make
    the expression clearer at a glance, but it is also obvious what it means
    when not using extra parentheses. It is common to have parentheses in situations where the operator precedence is not as well known, or may
    differ between programming languages - mixing bitwise and logical
    operators and equality operators are examples.

    You can get a reasonable balance using gcc's warnings - these also have
    the big advantage of making it easy to check! "-Wparentheses" (enabled
    by -Wall) will catch, for example, "a < b == c" which parses as "a < (b
    == c)". If "-Wparentheses" does not lead to complaints, then your
    generated code is probably okay without the extra parentheses - but you
    can still add them here if you prefer.

    In general, I think you want your generated code to pass "gcc -O2 -Wall" cleanly (or the clang equivalent, which is /not/ -Weverything!). You
    may even aim for -Wextra.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 09:17:08 2026
    From Newsgroup: comp.lang.c

    On 2026-11-06 08:49, David Brown wrote:
    [...]

    There is a proportion of programmers who think it is somehow blasphemy
    to use more parentheses in an expression than strictly necessary.-a [...]

    "blasphemy", wow! - The exaggerations (despite being here, allegedly,
    softened by the word "somehow") seem to have become in vogue, lately.
    (Formerly I saw such argumentation paths prevalently in one specific
    poster's posts only. Communication style seems to be infectious. :-)

    Most (all?) professionals seem to prefer clearness as you do. Whatever
    it needs to obtain that; less parentheses or additional parentheses -
    depending on the expressions' complexity and context! - Largely still subjective anyway, but less of religious intensity, I'd say.

    Janis

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Fri Nov 6 10:50:00 2026
    From Newsgroup: comp.lang.c

    On 06/11/2026 09:17, Janis Papanagnou wrote:
    On 2026-11-06 08:49, David Brown wrote:
    [...]

    There is a proportion of programmers who think it is somehow blasphemy
    to use more parentheses in an expression than strictly necessary.-a [...]

    "blasphemy", wow! - The exaggerations (despite being here, allegedly, softened by the word "somehow") seem to have become in vogue, lately. (Formerly I saw such argumentation paths prevalently in one specific
    poster's posts only. Communication style seems to be infectious. :-)

    I thought the term "blasphemy" was so obviously an exaggeration that it
    could not be taken realistically. I intended to point out that there
    are extreme views in both directions regarding additional parentheses
    that do not change the meaning of expressions in the C language.


    Most (all?) professionals seem to prefer clearness as you do. Whatever
    it needs to obtain that; less parentheses or additional parentheses - depending on the expressions' complexity and context! - Largely still subjective anyway, but less of religious intensity, I'd say.


    Some people do treat these things with a surprising intensity. But it
    is more common to pretend and tongue-in-check exaggerate their importance.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From James Kuyper@jameskuyper@alumni.caltech.edu to comp.lang.c++,comp.lang.c on Fri Nov 6 10:33:33 2026
    From Newsgroup: comp.lang.c

    On 2026-11-06 00:35, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]
    Otherwise, one or more parentheses
    might solve the problem.

    Technically correct (the best kind of correct), but *two* or more
    parentheses are even better.
    I should have said "... one or more matched pairs of parentheses ...".
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c++,comp.lang.c on Fri Nov 6 15:56:51 2026
    From Newsgroup: comp.lang.c

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-11-06 00:42, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for proper
    evaluation in C and/or C++?

    No, below (assuming i1 and j1 are arithmetic types (and not used
    as "camouflaged" booleans) there's no parenthesis necessary.

    The necessity of parentheses depends on the operators used. In
    "C" the multiplication has higher precedence than the comparison.

    I suggest to get an Operator Precedence Table from the Net and
    inspect it until you got familiar with the operator precedences.
    Most precedences are anyway sensibly defined as you'd expect it.
    But be careful when using bit-expressions with '&', '|', and '^'
    especially if used together with the comparison operators.

    Lynn has been working on his "fortran" -> "C++" conversion
    for over a decade now. That he isn't familar with the
    C operator precedence table is rather frightening.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 19:14:12 2026
    From Newsgroup: comp.lang.c

    On 2026-11-06 16:56, Scott Lurndal wrote:
    [...]

    Lynn has been working on his "fortran" -> "C++" conversion
    for over a decade now. That he isn't familar with the
    C operator precedence table is rather frightening.

    Well, astonishing. - But let's help those who ask for help. :-)

    Janis

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 19:18:36 2026
    From Newsgroup: comp.lang.c

    On 2026-11-06 10:50, David Brown wrote:
    On 06/11/2026 09:17, Janis Papanagnou wrote:
    On 2026-11-06 08:49, David Brown wrote:
    [...]

    There is a proportion of programmers who think it is somehow
    blasphemy to use more parentheses in an expression than strictly
    necessary.-a [...]

    "blasphemy", wow! - The exaggerations (despite being here, allegedly,
    softened by the word "somehow") seem to have become in vogue, lately.
    (Formerly I saw such argumentation paths prevalently in one specific
    poster's posts only. Communication style seems to be infectious. :-)

    I thought the term "blasphemy" was so obviously an exaggeration that it could not be taken realistically.-a[...]

    No worries. (You may have noticed my smiley?)

    But the intention of my post was also to make obvious to better
    not foster such language, even if it was meant as "accentuation".
    (You know how pathological some posters can get in that respect.)

    Janis

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 10:50:41 2026
    From Newsgroup: comp.lang.c

    David Brown <david.brown@hesbynett.no> writes:
    On 06/11/2026 02:07, Lynn McGuire wrote:
    On 11/5/2026 5:42 PM, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for
    proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }

    Thanks,
    Lynn
    Thank you all very much.-a BTW, there were parenthesis in the old
    Fortran code but F2C stripped them out.-a I put them back in for my
    comfort as I see them.


    Since you are generating the C++ code automatically, there should not
    be a problem adding the parentheses. Generated code that contains
    "goto L463" is clearly not intended for humans anyway (at least, not
    without a good deal of effort).

    My understanding is that the C++ code being generated is intended to be maintained as C++ code. Lynn can confirm or deny that. He's using f2c
    and a lot of manual cleanup.

    In this particular example:

    if ((j1 * i1) < 1)

    I find the inner parentheses slightly distracting. I'd wouldn't
    write it that way myself, but it wouldn't particularly bother me
    if I saw it in someone else's code, and I likely wouldn't mention
    it unless asked.

    If this were my project, as long as I'm having to do substantial
    manual cleanup, I'd probably change it to:

    if (j1 * i1) < 1)

    In a quick test, f2c didn't add parentheses given a Fortran input of
    "if (j1 * i1 < 1)". Either the inner parentheses were there in the
    Fortran code, or something else is going on.

    There is a proportion of programmers who think it is somehow blasphemy
    to use more parentheses in an expression than strictly necessary.
    That type of programmer will also disapprove of the extra braces
    around the "goto" in your example.

    Small quibble: The extra parentheses were in the condition in an "if" statement, not a goto. Parentheses in a "goto" statement would be a
    syntax error.

    [...]
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 13:16:40 2026
    From Newsgroup: comp.lang.c

    On 11/6/2026 7:56 AM, Scott Lurndal wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-11-06 00:42, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for proper
    evaluation in C and/or C++?

    No, below (assuming i1 and j1 are arithmetic types (and not used
    as "camouflaged" booleans) there's no parenthesis necessary.

    The necessity of parentheses depends on the operators used. In
    "C" the multiplication has higher precedence than the comparison.

    I suggest to get an Operator Precedence Table from the Net and
    inspect it until you got familiar with the operator precedences.
    Most precedences are anyway sensibly defined as you'd expect it.
    But be careful when using bit-expressions with '&', '|', and '^'
    especially if used together with the comparison operators.

    Lynn has been working on his "fortran" -> "C++" conversion
    for over a decade now. That he isn't familar with the
    C operator precedence table is rather frightening.


    Well, yeah. Shit.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 15:19:29 2026
    From Newsgroup: comp.lang.c

    On 11/6/2026 9:56 AM, Scott Lurndal wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-11-06 00:42, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for proper
    evaluation in C and/or C++?

    No, below (assuming i1 and j1 are arithmetic types (and not used
    as "camouflaged" booleans) there's no parenthesis necessary.

    The necessity of parentheses depends on the operators used. In
    "C" the multiplication has higher precedence than the comparison.

    I suggest to get an Operator Precedence Table from the Net and
    inspect it until you got familiar with the operator precedences.
    Most precedences are anyway sensibly defined as you'd expect it.
    But be careful when using bit-expressions with '&', '|', and '^'
    especially if used together with the comparison operators.

    Lynn has been working on his "fortran" -> "C++" conversion
    for over a decade now. That he isn't familar with the
    C operator precedence table is rather frightening.

    Since 2022 on and off. Customers have demands on my time.

    You are confusing the upgrading of my Fortran code from Fortran II to
    Fortran 66 that did take roughly a decade.

    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 13:25:10 2026
    From Newsgroup: comp.lang.c

    On 11/5/2026 11:49 PM, David Brown wrote:
    On 06/11/2026 02:07, Lynn McGuire wrote:
    On 11/5/2026 5:42 PM, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for proper
    evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }

    Thanks,
    Lynn

    Thank you all very much.-a BTW, there were parenthesis in the old
    Fortran code but F2C stripped them out.-a I put them back in for my
    comfort as I see them.


    Since you are generating the C++ code automatically, there should not be
    a problem adding the parentheses.-a Generated code that contains "goto
    L463" is clearly not intended for humans anyway (at least, not without a good deal of effort).

    There is a proportion of programmers who think it is somehow blasphemy
    to use more parentheses in an expression than strictly necessary.-a That type of programmer will also disapprove of the extra braces around the "goto" in your example.

    There is a proportion of programmers who think you should /always/ use parentheses to show the precedence of operators.

    Most programmers, I think, are in the middle.-a Parentheses here can make the expression clearer at a glance, but it is also obvious what it means when not using extra parentheses.

    Agreed. I don't mind extra parentheses at all. Totally fine, and can
    "help" in certain areas. I just happen to know about the order of
    operations.


    It is common to have parentheses in
    situations where the operator precedence is not as well known, or may
    differ between programming languages - mixing bitwise and logical
    operators and equality operators are examples.

    You can get a reasonable balance using gcc's warnings - these also have
    the big advantage of making it easy to check!-a "-Wparentheses" (enabled
    by -Wall) will catch, for example, "a < b == c" which parses as "a < (b
    == c)".-a If "-Wparentheses" does not lead to complaints, then your generated code is probably okay without the extra parentheses - but you
    can still add them here if you prefer.

    In general, I think you want your generated code to pass "gcc -O2 -Wall" cleanly (or the clang equivalent, which is /not/ -Weverything!).-a You
    may even aim for -Wextra.


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 15:27:44 2026
    From Newsgroup: comp.lang.c

    On 11/6/2026 12:50 PM, Keith Thompson wrote:
    David Brown <david.brown@hesbynett.no> writes:
    On 06/11/2026 02:07, Lynn McGuire wrote:
    On 11/5/2026 5:42 PM, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for
    proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }

    Thanks,
    Lynn
    Thank you all very much.-a BTW, there were parenthesis in the old
    Fortran code but F2C stripped them out.-a I put them back in for my
    comfort as I see them.


    Since you are generating the C++ code automatically, there should not
    be a problem adding the parentheses. Generated code that contains
    "goto L463" is clearly not intended for humans anyway (at least, not
    without a good deal of effort).

    My understanding is that the C++ code being generated is intended to be maintained as C++ code. Lynn can confirm or deny that. He's using f2c
    and a lot of manual cleanup.

    In this particular example:

    if ((j1 * i1) < 1)

    I find the inner parentheses slightly distracting. I'd wouldn't
    write it that way myself, but it wouldn't particularly bother me
    if I saw it in someone else's code, and I likely wouldn't mention
    it unless asked.

    If this were my project, as long as I'm having to do substantial
    manual cleanup, I'd probably change it to:

    if (j1 * i1) < 1)

    In a quick test, f2c didn't add parentheses given a Fortran input of
    "if (j1 * i1 < 1)". Either the inner parentheses were there in the
    Fortran code, or something else is going on.

    There is a proportion of programmers who think it is somehow blasphemy
    to use more parentheses in an expression than strictly necessary.
    That type of programmer will also disapprove of the extra braces
    around the "goto" in your example.

    Small quibble: The extra parentheses were in the condition in an "if" statement, not a goto. Parentheses in a "goto" statement would be a
    syntax error.

    [...]

    Yup, I am moving to C++ totally. Actually, a very mild version of C++
    for my 850,000 line calculation engine. No classes, all character
    strings in std::string variables, and a few other things. The old
    Fortran code was not type safe at all, the new C++ code is trying to use
    type safety everywhere.

    One of my worst experiences with Smalltalk was a crash in the software
    going to an error message with a crash in the error message due to a
    missing method in the Smalltalk class. We had happen way too often.

    Yes, I am using a heavily modified version of F2c and way too much
    manual cleanup. I need to modify F2C some more but probably will not as
    I am 40 or 45% code complete now.

    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 15:29:16 2026
    From Newsgroup: comp.lang.c

    On 11/6/2026 12:50 PM, Keith Thompson wrote:
    David Brown <david.brown@hesbynett.no> writes:
    On 06/11/2026 02:07, Lynn McGuire wrote:
    On 11/5/2026 5:42 PM, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for
    proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }

    Thanks,
    Lynn
    Thank you all very much.-a BTW, there were parenthesis in the old
    Fortran code but F2C stripped them out.-a I put them back in for my
    comfort as I see them.


    Since you are generating the C++ code automatically, there should not
    be a problem adding the parentheses. Generated code that contains
    "goto L463" is clearly not intended for humans anyway (at least, not
    without a good deal of effort).

    My understanding is that the C++ code being generated is intended to be maintained as C++ code. Lynn can confirm or deny that. He's using f2c
    and a lot of manual cleanup.

    In this particular example:

    if ((j1 * i1) < 1)

    I find the inner parentheses slightly distracting. I'd wouldn't
    write it that way myself, but it wouldn't particularly bother me
    if I saw it in someone else's code, and I likely wouldn't mention
    it unless asked.

    If this were my project, as long as I'm having to do substantial
    manual cleanup, I'd probably change it to:

    if (j1 * i1) < 1)...

    Huh? I am confused. Aren't you missing a left parenthesis there?

    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 13:29:27 2026
    From Newsgroup: comp.lang.c

    On 11/6/2026 10:50 AM, Keith Thompson wrote:
    David Brown <david.brown@hesbynett.no> writes:
    On 06/11/2026 02:07, Lynn McGuire wrote:
    On 11/5/2026 5:42 PM, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for
    proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }

    Thanks,
    Lynn
    Thank you all very much.-a BTW, there were parenthesis in the old
    Fortran code but F2C stripped them out.-a I put them back in for my
    comfort as I see them.


    Since you are generating the C++ code automatically, there should not
    be a problem adding the parentheses. Generated code that contains
    "goto L463" is clearly not intended for humans anyway (at least, not
    without a good deal of effort).

    My understanding is that the C++ code being generated is intended to be maintained as C++ code. Lynn can confirm or deny that. He's using f2c
    and a lot of manual cleanup.

    In this particular example:

    if ((j1 * i1) < 1)

    I find the inner parentheses slightly distracting. I'd wouldn't
    write it that way myself, but it wouldn't particularly bother me
    if I saw it in someone else's code, and I likely wouldn't mention
    it unless asked.

    If this were my project, as long as I'm having to do substantial
    manual cleanup, I'd probably change it to:


    if (j1 * i1) < 1)
    ^^^^^^^^^^^^^^^^^
    Why? Is that a syntax error? Afaict, the count of open and close
    parentheses do not match...


    In a quick test, f2c didn't add parentheses given a Fortran input of
    "if (j1 * i1 < 1)". Either the inner parentheses were there in the
    Fortran code, or something else is going on.

    There is a proportion of programmers who think it is somehow blasphemy
    to use more parentheses in an expression than strictly necessary.
    That type of programmer will also disapprove of the extra braces
    around the "goto" in your example.

    Small quibble: The extra parentheses were in the condition in an "if" statement, not a goto. Parentheses in a "goto" statement would be a
    syntax error.

    [...]


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 15:37:33 2026
    From Newsgroup: comp.lang.c

    On 11/6/2026 12:50 PM, Keith Thompson wrote:
    David Brown <david.brown@hesbynett.no> writes:
    On 06/11/2026 02:07, Lynn McGuire wrote:
    On 11/5/2026 5:42 PM, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for
    proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }

    Thanks,
    Lynn
    Thank you all very much.-a BTW, there were parenthesis in the old
    Fortran code but F2C stripped them out.-a I put them back in for my
    comfort as I see them.


    Since you are generating the C++ code automatically, there should not
    be a problem adding the parentheses. Generated code that contains
    "goto L463" is clearly not intended for humans anyway (at least, not
    without a good deal of effort).

    My understanding is that the C++ code being generated is intended to be maintained as C++ code. Lynn can confirm or deny that. He's using f2c
    and a lot of manual cleanup.
    ...

    Yes. I am tired of fixing the thousands of Fortran to C calls and C to Fortran calls when we move to a new Fortran compiler or a new C/C++
    compiler. This is one of the problems that has kept us on the obsolete
    Watcom F77/C/C++ compilers for over 30 years.

    I think I started putting C code into our Fortran calculation engine in
    1992 when a Japanese customer needed more memory for their Inline
    Fortran code inside our software (we have a Fortran 66 compiler and interpreter built into our software). I finally gave up giving them a
    special version every few months and moved all of the dynamic memory allocation code to using malloc, realloc, and free. Worked like a champ
    on the Unix and PC boxes, not so much on the mainframes and Vax
    refrigerators that were going away anyway.

    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Steven G. Kargl@sgk@REMOVEtroutmask.apl.washington.edu to comp.lang.c++,comp.lang.c on Fri Nov 6 21:48:28 2026
    From Newsgroup: comp.lang.c

    On Fri, 6 Nov 2026 15:37:33 -0600, Lynn McGuire wrote:

    On 11/6/2026 12:50 PM, Keith Thompson wrote:
    David Brown <david.brown@hesbynett.no> writes:
    On 06/11/2026 02:07, Lynn McGuire wrote:
    On 11/5/2026 5:42 PM, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for
    proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }

    Thanks,
    Lynn
    Thank you all very much.-a BTW, there were parenthesis in the old
    Fortran code but F2C stripped them out.-a I put them back in for my
    comfort as I see them.


    Since you are generating the C++ code automatically, there should not
    be a problem adding the parentheses. Generated code that contains
    "goto L463" is clearly not intended for humans anyway (at least, not
    without a good deal of effort).

    My understanding is that the C++ code being generated is intended to be
    maintained as C++ code. Lynn can confirm or deny that. He's using f2c
    and a lot of manual cleanup.
    ...

    Yes. I am tired of fixing the thousands of Fortran to C calls and C to Fortran calls when we move to a new Fortran compiler or a new C/C++ compiler. This is one of the problems that has kept us on the obsolete Watcom F77/C/C++ compilers for over 30 years.


    Fortran's ISO C binding feature fixed this Fortran <--> C issue some
    20 years ago. Granted, CFI was not available until 2018.
    --
    steve
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.c++,comp.lang.c on Fri Nov 6 21:51:58 2026
    From Newsgroup: comp.lang.c

    On Fri, 6 Nov 2026 15:27:44 -0600, Lynn McGuire wrote:

    Yup, I am moving to C++ totally. Actually, a very mild version of
    C++ for my 850,000 line calculation engine. No classes, all
    character strings in std::string variables, and a few other things.
    The old Fortran code was not type safe at all, the new C++ code is
    trying to use type safety everywhere.

    One thing I found useful in C++ code is using the explicit
    rCLxxx_cast<...>rCY operators instead of the catch-all C-style prefix-with-type-spec-in-parentheses. These are easier to search for,
    and also easier to make more specific (i.e. only using
    reinterpret_cast<> where absolutely necessary).
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 14:23:44 2026
    From Newsgroup: comp.lang.c

    Lynn McGuire <lynnmcguire5@gmail.com> writes:
    On 11/6/2026 12:50 PM, Keith Thompson wrote:
    [...]
    If this were my project, as long as I'm having to do substantial
    manual cleanup, I'd probably change it to:
    if (j1 * i1) < 1)...

    Huh? I am confused. Aren't you missing a left parenthesis there?

    Yes, that was just a typo. I meant:

    if (j1 * i1 < 1)

    My point is that *for me*, the fact that "*" binds more tightly than
    "<" is so obvious that I find extra parentheses mildly distracting.
    Of course both forms are obviously correct.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Fri Nov 6 16:34:29 2026
    From Newsgroup: comp.lang.c

    On 11/6/2026 3:48 PM, Steven G. Kargl wrote:
    On Fri, 6 Nov 2026 15:37:33 -0600, Lynn McGuire wrote:

    On 11/6/2026 12:50 PM, Keith Thompson wrote:
    David Brown <david.brown@hesbynett.no> writes:
    On 06/11/2026 02:07, Lynn McGuire wrote:
    On 11/5/2026 5:42 PM, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for
    proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }

    Thanks,
    Lynn
    Thank you all very much.-a BTW, there were parenthesis in the old
    Fortran code but F2C stripped them out.-a I put them back in for my
    comfort as I see them.


    Since you are generating the C++ code automatically, there should not
    be a problem adding the parentheses. Generated code that contains
    "goto L463" is clearly not intended for humans anyway (at least, not
    without a good deal of effort).

    My understanding is that the C++ code being generated is intended to be
    maintained as C++ code. Lynn can confirm or deny that. He's using f2c
    and a lot of manual cleanup.
    ...

    Yes. I am tired of fixing the thousands of Fortran to C calls and C to
    Fortran calls when we move to a new Fortran compiler or a new C/C++
    compiler. This is one of the problems that has kept us on the obsolete
    Watcom F77/C/C++ compilers for over 30 years.


    Fortran's ISO C binding feature fixed this Fortran <--> C issue some
    20 years ago. Granted, CFI was not available until 2018.

    I found the ISO C binding to be lacking and not type safe to my standard.

    I also was not enthusiastic about installing it in thousands of places
    in my code.

    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Oodini@svdbg@free.fr to comp.lang.c++,comp.lang.c on Fri Nov 6 23:41:08 2026
    From Newsgroup: comp.lang.c

    Le 06/11/2026 |a 00:42, Lynn McGuire a |-crit-a:

    Does an expression in a logical statement need parenthesis for proper evaluation in C and/or C++?

    No, but adding parentheses may be wished to make explicit the
    evaluation. Ie, it is suggested by MISRA C++:2023 :

    https://www.mathworks.com/help/bugfinder/ref/misracpp2023rule8.0.1.html
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Sat Nov 7 12:38:07 2026
    From Newsgroup: comp.lang.c

    On 06/11/2026 19:18, Janis Papanagnou wrote:
    On 2026-11-06 10:50, David Brown wrote:
    On 06/11/2026 09:17, Janis Papanagnou wrote:
    On 2026-11-06 08:49, David Brown wrote:
    [...]

    There is a proportion of programmers who think it is somehow
    blasphemy to use more parentheses in an expression than strictly
    necessary.-a [...]

    "blasphemy", wow! - The exaggerations (despite being here, allegedly,
    softened by the word "somehow") seem to have become in vogue, lately.
    (Formerly I saw such argumentation paths prevalently in one specific
    poster's posts only. Communication style seems to be infectious. :-)

    I thought the term "blasphemy" was so obviously an exaggeration that
    it could not be taken realistically.-a[...]

    No worries. (You may have noticed my smiley?)

    But the intention of my post was also to make obvious to better
    not foster such language, even if it was meant as "accentuation".
    (You know how pathological some posters can get in that respect.)


    Yes, Poe's Law is a real phenomenon!


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Sat Nov 7 12:48:14 2026
    From Newsgroup: comp.lang.c

    On 06/11/2026 19:50, Keith Thompson wrote:
    David Brown <david.brown@hesbynett.no> writes:
    On 06/11/2026 02:07, Lynn McGuire wrote:
    On 11/5/2026 5:42 PM, Lynn McGuire wrote:
    Hi,

    Does an expression in a logical statement need parenthesis for
    proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }

    Thanks,
    Lynn
    Thank you all very much.-a BTW, there were parenthesis in the old
    Fortran code but F2C stripped them out.-a I put them back in for my
    comfort as I see them.


    Since you are generating the C++ code automatically, there should not
    be a problem adding the parentheses. Generated code that contains
    "goto L463" is clearly not intended for humans anyway (at least, not
    without a good deal of effort).

    My understanding is that the C++ code being generated is intended to be maintained as C++ code. Lynn can confirm or deny that. He's using f2c
    and a lot of manual cleanup.


    Okay. If that is the case, however, I'd worry more about the "goto
    L463" than an extra set of parentheses.

    My impression is that he is still fiddling with his fork of f2c with an
    aim to getting as much automation as he can to minimise the manual
    cleanup, but I could easily be wrong here. I have no idea if it is
    possible to automate something to help with such gotos.

    In this particular example:

    if ((j1 * i1) < 1)

    I find the inner parentheses slightly distracting. I'd wouldn't
    write it that way myself, but it wouldn't particularly bother me
    if I saw it in someone else's code, and I likely wouldn't mention
    it unless asked.

    If this were my project, as long as I'm having to do substantial
    manual cleanup, I'd probably change it to:

    if (j1 * i1) < 1)

    I suspect you'd change it to something with balanced parentheses :-)

    I personally would probably have the extra parentheses, but I would not
    be concerned about code that lacked it.


    In a quick test, f2c didn't add parentheses given a Fortran input of
    "if (j1 * i1 < 1)". Either the inner parentheses were there in the
    Fortran code, or something else is going on.

    There is a proportion of programmers who think it is somehow blasphemy
    to use more parentheses in an expression than strictly necessary.
    That type of programmer will also disapprove of the extra braces
    around the "goto" in your example.

    Small quibble: The extra parentheses were in the condition in an "if" statement, not a goto. Parentheses in a "goto" statement would be a
    syntax error.


    I was talking about the extra braces, not extra parentheses - i.e.,

    if (j1 * i1 < 1) {
    goto L463;
    }

    vs.

    if (j1 * i1 < 1)
    goto L463;


    This is again a matter of style. I guess Lynn's aim will be to have his version of f2c generate as good a match for the style he wants, to
    reduce the manual post-processing.




    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Sat Nov 7 20:39:46 2026
    From Newsgroup: comp.lang.c

    On 2026-11-07 12:48, David Brown wrote:
    [...]

    My impression is that he is still fiddling with his fork of f2c with an
    aim to getting as much automation as he can to minimise the manual
    cleanup, but I could easily be wrong here.-a I have no idea if it is possible to automate something to help with such gotos.

    It might suffice for such an automation tasks to just mirror such
    'goto' structures (unless you intend to create better structured
    code through code transformations). - Not long ago I refactored a
    legacy program to obtain an equivalent implementation in another
    language and the de-spaghettifying turned out to have been really
    nasty. (The code had severely convoluted 'goto's and not a single
    structured element.) - In principal it's possible to de-'goto' any
    source code to obtain structured code. Since I've no experience
    with such tools I'm curious what experiences exists in that respect,
    especially for trans-language transformations (from a heavily 'goto'
    biased language (BASIC, FORTRAN?) to some structured language). -
    While looking into the Net and concerning this thread I stumbled
    across this reply, though:
    "f2c or pet (for Fortran/C): Older research tools designed
    to parse flat code graphs and reconstruct clean, structured
    if/else and loop components."
    which gave the impression that 'f2c' would be able to remove those
    'goto's and so I'm wondering why there's (still) 'goto's in the
    OP's sample code.

    Janis

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c++,comp.lang.c on Sat Nov 7 12:29:51 2026
    From Newsgroup: comp.lang.c

    On 11/7/2026 11:39 AM, Janis Papanagnou wrote:
    On 2026-11-07 12:48, David Brown wrote:
    [...]

    My impression is that he is still fiddling with his fork of f2c with
    an aim to getting as much automation as he can to minimise the manual
    cleanup, but I could easily be wrong here.-a I have no idea if it is
    possible to automate something to help with such gotos.

    It might suffice for such an automation tasks to just mirror such
    'goto' structures (unless you intend to create better structured
    code through code transformations). - Not long ago I refactored a
    legacy program to obtain an equivalent implementation in another
    language and the de-spaghettifying turned out to have been really
    nasty. (The code had severely convoluted 'goto's and not a single
    structured element.) - In principal it's possible to de-'goto' any
    source code to obtain structured code. Since I've no experience
    with such tools I'm curious what experiences exists in that respect, especially for trans-language transformations (from a heavily 'goto'
    biased language (BASIC, FORTRAN?) to some structured language). -
    While looking into the Net and concerning this thread I stumbled
    across this reply, though:
    -a "f2c or pet (for Fortran/C): Older research tools designed
    -a-a to parse flat code graphs and reconstruct clean, structured
    -a-a if/else and loop components."
    which gave the impression that 'f2c' would be able to remove those
    'goto's and so I'm wondering why there's (still) 'goto's in the
    OP's sample code.
    Fwiw, I ported some of my work over to AppleSoft BASIC just to show it
    can be portable. But, my work needed some recursion. BASIC, good luck. However, there is a way, giving BASIC a stack. So for a simple Koch
    fractal based on any line:

    https://pastebin.com/raw/Effeg8cK

    100 REM ct_vfield_applesoft_basic
    110 HOME
    120 HGR: HCOLOR = 3: VTAB 22
    130 PRINT "ct_vfield_applesoft_basic"
    140 GOSUB 1000
    150 GOSUB 3000
    160 SP = 0
    170 RS(SP, 0) = 0
    180 RS(SP, 1) = -1
    190 RS(SP, 2) = 0
    200 RS(SP, 3) = 1
    210 RS(SP, 4) = 0
    220 GOSUB 8000
    230 V1(1) = 0: V1(2) = 0: V1(3) = 1: V1(4) = 128
    240 GOSUB 6000
    245 PRINT "Chris Thomasson's Koch Complete!"
    250 END

    1000 REM ct_init
    1010 PRINT "ct_init"
    1020 DIM A0(6)
    1030 DIM V0(4)
    1040 DIM V1(4)
    1050 DIM V2(4)
    1060 DIM V3(4)
    1070 DIM V4(4)
    1080 DIM V5(4)
    1090 RN = 3
    1100 DIM RS(RN, 16)
    1110 GOSUB 2000
    1120 RETURN

    2000 REM ct_init_plane
    2010 PRINT "ct_init_plane"
    2020 A0(1) = 279: REM m_plane.m_width
    2030 A0(2) = 191: REM m_plane.m_height
    2040 A0(3) = 0.0126106: REM m_plane.m_xstep
    2050 A0(4) = 0.0126316: REM m_plane.m_ystep
    2060 A0(5) = -1.75288: REM m_plane.m_axes.m_xmin
    2070 A0(6) = 1.2: REM m_plane.m_axes.m_ymax
    2080 RETURN

    3000 REM ct_display_plane
    3010 PRINT "ct_display_plane"
    3020 FOR I0 = 1 TO 6
    3030 PRINT "A0("; I0; ") = " A0(I0)
    3040 NEXT I0
    3050 RETURN

    4000 REM ct_project_point
    4010 REM PRINT "ct_project_point"
    4020 V0(3) = (V0(1) - A0(5)) / A0(3)
    4030 V0(4) = (A0(6) - V0(2)) / A0(4)
    4040 IF V0(3) < 0 THEN V0(3) = INT(V0(3) - .5)
    4050 IF V0(3) >= 0 THEN V0(3) = INT(V0(3) + .5)
    4060 IF V0(4) < 0 THEN V0(4) = INT(V0(4) - .5)
    4070 IF V0(4) >= 0 THEN V0(4) = INT(V0(4) + .5)
    4080 RETURN

    5000 REM ct_plot_point
    5010 REM PRINT "ct_plot_point"
    5020 GOSUB 4000
    5030 IF V0(3) > -1 AND V0(3) <= A0(1) AND V0(4) > -1 AND V0(4) <=
    A0(2) THEN HPLOT V0(3), V0(4)
    5040 RETURN

    6000 REM ct_plot_circle
    6010 PRINT "ct_plot_circle"
    6020 AB = 6.28318 / V1(4)
    6030 FOR I1 = 0 TO 6.28318 STEP AB
    6040 V0(1) = V1(1) + COS(I1) * V1(3)
    6050 V0(2) = V1(2) + SIN(I1) * V1(3)
    6060 GOSUB 5000
    6070 NEXT I1
    6080 RETURN

    7000 REM ct_plot_line
    7010 PRINT "ct_plot_line"
    7020 V0(1) = V5(1): V0(2) = V5(2)
    7030 GOSUB 4000
    7040 IF V0(3) < 0 THEN V0(3) = 0
    7050 IF V0(3) > A0(1) THEN V0(3) = A0(1)
    7060 IF V0(4) < 0 THEN V0(4) = 0
    7070 IF V0(4) > A0(2) THEN V0(4) = A0(2)
    7080 HPLOT V0(3), V0(4)
    7090 V0(1) = V5(3): V0(2) = V5(4)
    7100 GOSUB 4000
    7110 IF V0(3) < 0 THEN V0(3) = 0
    7120 IF V0(3) > A0(1) THEN V0(3) = A0(1)
    7130 IF V0(4) < 0 THEN V0(4) = 0
    7140 IF V0(4) > A0(2) THEN V0(4) = A0(2)
    7150 HPLOT TO V0(3), V0(4)
    7160 RETURN

    8000 REM ct_koch
    8010 IF RS(SP, 0) >= RN THEN RETURN
    8020 PRINT "ct_koch = "; RS(SP, 0); " "; RS(SP, 1); " "; RS(SP, 2);
    " "; RS(SP, 3); " "; RS(SP, 4)"
    8030 RS(SP, 5) = RS(SP, 3) - RS(SP, 1) : REM difx
    8040 RS(SP, 6) = RS(SP, 4) - RS(SP, 2) : REM dify
    8050 RS(SP, 7) = RS(SP, 1) + RS(SP, 5) / 2 : REM dify
    8060 RS(SP, 8) = RS(SP, 2) + RS(SP, 6) / 2 : REM dify
    8070 RS(SP, 9) = -RS(SP, 6) : REM perpx
    8080 RS(SP, 10) = RS(SP, 5) : REM perpy
    8090 RS(SP, 11) = RS(SP, 7) + RS(SP, 9) / 3 : REM tipx
    8100 RS(SP, 12) = RS(SP, 8) + RS(SP, 10) / 3 : REM tipy
    8110 RS(SP, 13) = RS(SP, 1) + RS(SP, 5) / 3 : REM k0x
    8120 RS(SP, 14) = RS(SP, 2) + RS(SP, 6) / 3 : REM k0y
    8130 RS(SP, 15) = RS(SP, 3) - RS(SP, 5) / 3 : REM k1x
    8140 RS(SP, 16) = RS(SP, 4) - RS(SP, 6) / 3 : REM k1y

    8145 IF RS(SP, 0) < RN - 1 GOTO 8230
    8150 V5(1) = RS(SP, 1): V5(2) = RS(SP, 2): V5(3) = RS(SP, 13): V5(4)
    = RS(SP, 14)
    8160 GOSUB 7000
    8170 V5(1) = RS(SP, 13): V5(2) = RS(SP, 14): V5(3) = RS(SP, 11):
    V5(4) = RS(SP, 12)
    8180 GOSUB 7000
    8190 V5(1) = RS(SP, 11): V5(2) = RS(SP, 12): V5(3) = RS(SP, 15):
    V5(4) = RS(SP, 16)
    8200 GOSUB 7000
    8210 V5(1) = RS(SP, 15): V5(2) = RS(SP, 16): V5(3) = RS(SP, 3):
    V5(4) = RS(SP, 4)
    8220 GOSUB 7000

    8230 REM line 0
    8240 SP = SP + 1
    8250 RS(SP, 0) = RS(SP - 1, 0) + 1
    8260 RS(SP, 1) = RS(SP - 1, 1)
    8270 RS(SP, 2) = RS(SP - 1, 2)
    8280 RS(SP, 3) = RS(SP - 1, 13)
    8290 RS(SP, 4) = RS(SP - 1, 14)
    8300 GOSUB 8000
    8310 SP = SP - 1
    8320 REM line 1
    8330 SP = SP + 1
    8340 RS(SP, 0) = RS(SP - 1, 0) + 1
    8350 RS(SP, 1) = RS(SP - 1, 13)
    8360 RS(SP, 2) = RS(SP - 1, 14)
    8370 RS(SP, 3) = RS(SP - 1, 11)
    8380 RS(SP, 4) = RS(SP - 1, 12)
    8390 GOSUB 8000
    8400 SP = SP - 1
    8410 REM line 2
    8420 SP = SP + 1
    8430 RS(SP, 0) = RS(SP - 1, 0) + 1
    8440 RS(SP, 1) = RS(SP - 1, 11)
    8450 RS(SP, 2) = RS(SP - 1, 12)
    8460 RS(SP, 3) = RS(SP - 1, 15)
    8470 RS(SP, 4) = RS(SP - 1, 16)
    8480 GOSUB 8000
    8490 SP = SP - 1
    8500 REM line 3
    8510 SP = SP + 1
    8520 RS(SP, 0) = RS(SP - 1, 0) + 1
    8530 RS(SP, 1) = RS(SP - 1, 15)
    8540 RS(SP, 2) = RS(SP - 1, 16)
    8550 RS(SP, 3) = RS(SP - 1, 3)
    8560 RS(SP, 4) = RS(SP - 1, 4)
    8570 GOSUB 8000
    8580 SP = SP - 1
    8590 RETURN


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Sat Nov 7 14:39:55 2026
    From Newsgroup: comp.lang.c

    On 11/7/2026 1:39 PM, Janis Papanagnou wrote:
    On 2026-11-07 12:48, David Brown wrote:
    [...]

    My impression is that he is still fiddling with his fork of f2c with
    an aim to getting as much automation as he can to minimise the manual
    cleanup, but I could easily be wrong here.-a I have no idea if it is
    possible to automate something to help with such gotos.

    It might suffice for such an automation tasks to just mirror such
    'goto' structures (unless you intend to create better structured
    code through code transformations). - Not long ago I refactored a
    legacy program to obtain an equivalent implementation in another
    language and the de-spaghettifying turned out to have been really
    nasty. (The code had severely convoluted 'goto's and not a single
    structured element.) - In principal it's possible to de-'goto' any
    source code to obtain structured code. Since I've no experience
    with such tools I'm curious what experiences exists in that respect, especially for trans-language transformations (from a heavily 'goto'
    biased language (BASIC, FORTRAN?) to some structured language). -
    While looking into the Net and concerning this thread I stumbled
    across this reply, though:
    -a "f2c or pet (for Fortran/C): Older research tools designed
    -a-a to parse flat code graphs and reconstruct clean, structured
    -a-a if/else and loop components."
    which gave the impression that 'f2c' would be able to remove those
    'goto's and so I'm wondering why there's (still) 'goto's in the
    OP's sample code.

    Janis

    F2C is automagically restructuring my code to the first level. Maybe
    the second level sometimes. The number of gotos is reduced by 80 or
    90%. Way past the point that I don't care. If a goto is jumping
    halfway down a method then replacing it with a monster if then is just
    crazy so F2C skips that case. I am not modifying F2C anymore.

    If wanted, I can post comparisons of a couple of my subroutines and the resulting methods.

    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Sun Nov 8 01:30:04 2026
    From Newsgroup: comp.lang.c

    On 2026-11-07 21:39, Lynn McGuire wrote:
    On 11/7/2026 1:39 PM, Janis Papanagnou wrote:
    [...]
    While looking into the Net and concerning this thread I stumbled
    across this reply, though:
    -a-a "f2c or pet (for Fortran/C): Older research tools designed
    -a-a-a to parse flat code graphs and reconstruct clean, structured
    -a-a-a if/else and loop components."
    which gave the impression that 'f2c' would be able to remove those
    'goto's and so I'm wondering why there's (still) 'goto's in the
    OP's sample code.

    F2C is automagically restructuring my code to the first level.-a Maybe
    the second level sometimes.-a The number of gotos is reduced by 80 or
    90%.-a Way past the point that I don't care.-a If a goto is jumping
    halfway down a method then replacing it with a monster if then is just
    crazy so F2C skips that case.-a I am not modifying F2C anymore.

    Thanks for that background information.

    If wanted, I can post comparisons of a couple of my subroutines and the resulting methods.

    Don't bother, since I'm not doing Fortran, I was just interested
    in principle here.

    Your numbers of 80-90% reduction is, I think, quite good already.
    But given that your C-code sample's label number is still "L463"
    I don't want to see that code; I'm still traumatized by the code
    that I had tried to de-goto-fy not long ago.

    Janis

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Sun Nov 8 01:39:15 2026
    From Newsgroup: comp.lang.c

    On 2026-11-07 21:29, Chris M. Thomasson wrote:
    Fwiw, I ported some of my work over to AppleSoft BASIC just to show it
    can be portable. But, my work needed some recursion. BASIC, good luck. However, there is a way, giving BASIC a stack. So for a simple Koch
    fractal based on any line:
    [snip]
    4040-a-a-a-a IF V0(3) < 0 THEN V0(3) = INT(V0(3) - .5)

    It's obviously at least a dialect that allowed a statement after the
    'then', as opposed to just a line number (as it had been in the early dialects). Having only absolute jumps and conditional jumps is really
    a pain.

    Janis

    [...]

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Sat Nov 7 19:13:20 2026
    From Newsgroup: comp.lang.c

    On 11/7/2026 6:30 PM, Janis Papanagnou wrote:
    On 2026-11-07 21:39, Lynn McGuire wrote:
    On 11/7/2026 1:39 PM, Janis Papanagnou wrote:
    [...]
    While looking into the Net and concerning this thread I stumbled
    across this reply, though:
    -a-a "f2c or pet (for Fortran/C): Older research tools designed
    -a-a-a to parse flat code graphs and reconstruct clean, structured
    -a-a-a if/else and loop components."
    which gave the impression that 'f2c' would be able to remove those
    'goto's and so I'm wondering why there's (still) 'goto's in the
    OP's sample code.

    F2C is automagically restructuring my code to the first level.-a Maybe
    the second level sometimes.-a The number of gotos is reduced by 80 or
    90%.-a Way past the point that I don't care.-a If a goto is jumping
    halfway down a method then replacing it with a monster if then is just
    crazy so F2C skips that case.-a I am not modifying F2C anymore.

    Thanks for that background information.

    If wanted, I can post comparisons of a couple of my subroutines and
    the resulting methods.

    Don't bother, since I'm not doing Fortran, I was just interested
    in principle here.

    Your numbers of 80-90% reduction is, I think, quite good already.
    But given that your C-code sample's label number is still "L463"
    I don't want to see that code; I'm still traumatized by the code
    that I had tried to de-goto-fy not long ago.

    Janis

    At least I do not have any "come from"s in my code.

    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Sun Nov 8 09:55:41 2026
    From Newsgroup: comp.lang.c

    On 2026-11-08 02:13, Lynn McGuire wrote:
    On 11/7/2026 6:30 PM, Janis Papanagnou wrote:
    [...] I'm still traumatized by the code
    that I had tried to de-goto-fy not long ago.

    At least I do not have any "come from"s in my code.

    :-)

    I suppose you have Intercal in mind? ;-)

    Janis

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Andrey Tarasevich@noone@noone.net to comp.lang.c++,comp.lang.c on Sun Nov 8 23:32:25 2026
    From Newsgroup: comp.lang.c

    On Thu 11/5/2026 3:42 PM, Lynn McGuire wrote:
    Does an expression in a logical statement need parenthesis for proper evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a goto L463;
    }

    The whole `j1 * i1 < 1` is an expression in this case. It is parsed in accordance with the grammar, which ultimately makes it equivalent to
    `(j1 * i1) < 1`.

    Your question seems to suggest that the `j1 * i1` part somehow qualifies
    as an expression, while the rest of it does not. That's not how it
    works. The language does not give the `j1 * i1` part any special status.
    --
    Best regards,
    Andrey
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Bonita Montero@Bonita.Montero@gmail.com to comp.lang.c++,comp.lang.c on Mon Nov 9 10:03:20 2026
    From Newsgroup: comp.lang.c

    Am 06.11.2026 um 00:42 schrieb Lynn McGuire:

    if (j1 * i1 < 1) {
    -a-a-a goto L463;
    }
    ...
    if ((j1 * i1) < 1) {
    -a-a-a goto L463;
    }
    The latter one leads to more optimized code !
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From James Kuyper@jameskuyper@alumni.caltech.edu to comp.lang.c++,comp.lang.c on Mon Nov 9 06:00:40 2026
    From Newsgroup: comp.lang.c

    On 2026-11-09 02:32, Andrey Tarasevich wrote:
    On Thu 11/5/2026 3:42 PM, Lynn McGuire wrote:
    Does an expression in a logical statement need parenthesis for proper
    evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a goto L463;
    }

    The whole `j1 * i1 < 1` is an expression in this case. It is parsed in accordance with the grammar, which ultimately makes it equivalent to
    `(j1 * i1) < 1`.

    Your question seems to suggest that the `j1 * i1` part somehow qualifies
    as an expression, while the rest of it does not. That's not how it
    works. The language does not give the `j1 * i1` part any special status.
    You are correct, parentheses are not needed. However, there's a related question that could have a different answer: should an arithmetic
    expression that is an operand of a comparison expression be
    parenthesized - not because it needs the parenthesis, but to clarify
    what the grammar already guarantees?
    I tend not to use unnecessary parentheses, and I know the grammar well
    enough to correctly identify them - but many people don't know the
    grammar that well, which might include the next person to maintain my
    code. There are reasonable arguments that I should use parentheses more
    than I actually do, for the benefit of such people.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Mon Nov 9 14:24:02 2026
    From Newsgroup: comp.lang.c

    On 11/8/2026 2:55 AM, Janis Papanagnou wrote:
    On 2026-11-08 02:13, Lynn McGuire wrote:
    On 11/7/2026 6:30 PM, Janis Papanagnou wrote:
    [...]-a I'm still traumatized by the code
    that I had tried to de-goto-fy not long ago.

    At least I do not have any "come from"s in my code.

    :-)

    I suppose you have Intercal in mind? ;-)

    Janis

    Fortran of course.
    https://en.wikipedia.org/wiki/COMEFROM

    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Mon Nov 9 21:42:08 2026
    From Newsgroup: comp.lang.c

    On 2026-11-09 12:00, James Kuyper wrote:
    On 2026-11-09 02:32, Andrey Tarasevich wrote:
    On Thu 11/5/2026 3:42 PM, Lynn McGuire wrote:
    Does an expression in a logical statement need parenthesis for proper
    evaluation in C and/or C++?

    In other words, should

    if (j1 * i1 < 1) {
    -a-a-a goto L463;
    }

    be

    if ((j1 * i1) < 1) {
    -a-a-a goto L463;
    }

    The whole `j1 * i1 < 1` is an expression in this case. It is parsed in
    accordance with the grammar, which ultimately makes it equivalent to
    `(j1 * i1) < 1`.

    Your question seems to suggest that the `j1 * i1` part somehow qualifies
    as an expression, while the rest of it does not. That's not how it
    works. The language does not give the `j1 * i1` part any special status.

    You are correct, parentheses are not needed. However, there's a related question that could have a different answer: should an arithmetic
    expression that is an operand of a comparison expression be
    parenthesized - not because it needs the parenthesis, but to clarify
    what the grammar already guarantees?

    I observed that most grammars are consistently defined and have the
    semantics what one expects. ("C" with &, |, ^ being with this detail
    the obvious exception.) In some other well-known languages you even
    need parentheses in expressions with mixed types. (Remember Pascal
    with expressions like "(12 < 42) AND (33 >= 21)"; but here you will
    just get a syntax error when omitting the parentheses, so it's safe.)
    The problem with "C", beyond the mentioned bit-operations case, is
    that there had been just one integral "type" and all operations were
    applicable between integers, "characters", and "booleans", and that
    they all "make sense" here. So type-safety of a language plays a role, presuming the language (not "C") has a sensible differentiated set of
    types. While for arithmetic the rules are (mostly) as you'd expect
    them to be I'm usually using parenthesis to signify precedence within
    the bool type in complex expressions containing mixtures of '&&' and
    '||' - that's of course my personal thing.

    I tend not to use unnecessary parentheses, and I know the grammar well
    enough to correctly identify them - but many people don't know the
    grammar that well, which might include the next person to maintain my
    code. There are reasonable arguments that I should use parentheses more
    than I actually do, for the benefit of such people.

    I'm "a bit" unsettled by the idea of a programmer who is unfamiliar
    with the language in general or the grammar specifically! (I know
    there's such folks writing programs.) I wouldn't write programs in
    ways to satisfy such folks. I'd certainly write programs in ways to
    keep the program maintainable focusing on the language specifics not
    imagining that the piece of code might be handled by a Neanderthal.

    (But that's also a topic of management; will they employ professional programmers, do they install coding guidelines, will their processes
    include QA means, etc. That's handled primarily on an organizational
    level. For private programming it's even less an issue to consider
    the worst case of some uninitiated working with your programs.)

    I think the most benefit for parentheses is to visually structure
    expressions that are very complex. While other means support that,
    like in-line spacing and formatting an expression across more lines,
    the parentheses are the prominent way to make the expression actually
    *do* what is written so are unambiguous (as is splitting an expression explicitly into sub-expressions).

    Janis

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Mon Nov 9 21:51:16 2026
    From Newsgroup: comp.lang.c

    On 2026-11-09 21:24, Lynn McGuire wrote:
    On 11/8/2026 2:55 AM, Janis Papanagnou wrote:
    On 2026-11-08 02:13, Lynn McGuire wrote:
    On 11/7/2026 6:30 PM, Janis Papanagnou wrote:
    [...]-a I'm still traumatized by the code
    that I had tried to de-goto-fy not long ago.

    At least I do not have any "come from"s in my code.

    :-)

    I suppose you have Intercal in mind? ;-)

    Fortran of course.
    -a-a https://en.wikipedia.org/wiki/COMEFROM

    Jesus! 8-o

    Interesting article; I didn't know that "joke" was
    considered also by those more serious languages.

    Janis

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.c++,comp.lang.c on Mon Nov 9 22:41:14 2026
    From Newsgroup: comp.lang.c

    On Mon, 9 Nov 2026 06:00:40 -0500, James Kuyper wrote:

    I tend not to use unnecessary parentheses, and I know the grammar
    well enough to correctly identify them - but many people don't know
    the grammar that well, which might include the next person to
    maintain my code.

    Even if they havenrCOt committed the precedence table to memory, surely
    they have the ability to look things up online <https://en.cppreference.com/c/language/operator_precedence>.

    If someone has regular trouble with certain language features, why
    arenrCOt pages that clarify those very issues not already in their
    browser bookmarks?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c++,comp.lang.c on Mon Nov 9 16:54:19 2026
    From Newsgroup: comp.lang.c

    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:
    On Mon, 9 Nov 2026 06:00:40 -0500, James Kuyper wrote:
    I tend not to use unnecessary parentheses, and I know the grammar
    well enough to correctly identify them - but many people don't know
    the grammar that well, which might include the next person to
    maintain my code.

    Even if they havenrCOt committed the precedence table to memory, surely
    they have the ability to look things up online <https://en.cppreference.com/c/language/operator_precedence>.

    If someone has regular trouble with certain language features, why
    arenrCOt pages that clarify those very issues not already in their
    browser bookmarks?

    If I haven't memorized all the precedence levels, I greatly prefer
    an expression I can read at a glance to one that requires me to
    consult some document before I can be sure what it means, just so
    I can continue to the next line of code.

    Just one example: I couldn't tell you whether `^` or `|` binds more
    tightly without looking it up. If you can, that's great.

    Preferences for *how many* strictly semantically unnecessary
    parentheses are appropriate vary greatly, but few C programmers
    would insist on none.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c++,comp.lang.c on Mon Nov 9 17:05:04 2026
    From Newsgroup: comp.lang.c

    On 11/9/2026 4:54 PM, Keith Thompson wrote:
    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:
    On Mon, 9 Nov 2026 06:00:40 -0500, James Kuyper wrote:
    I tend not to use unnecessary parentheses, and I know the grammar
    well enough to correctly identify them - but many people don't know
    the grammar that well, which might include the next person to
    maintain my code.

    Even if they havenrCOt committed the precedence table to memory, surely
    they have the ability to look things up online
    <https://en.cppreference.com/c/language/operator_precedence>.

    If someone has regular trouble with certain language features, why
    arenrCOt pages that clarify those very issues not already in their
    browser bookmarks?

    If I haven't memorized all the precedence levels, I greatly prefer
    an expression I can read at a glance to one that requires me to
    consult some document before I can be sure what it means, just so
    I can continue to the next line of code.

    Just one example: I couldn't tell you whether `^` or `|` binds more
    tightly without looking it up. If you can, that's great.

    Preferences for *how many* strictly semantically unnecessary
    parentheses are appropriate vary greatly, but few C programmers
    would insist on none.


    Perfectly fair enough. Good.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Mon Nov 9 22:39:04 2026
    From Newsgroup: comp.lang.c

    On 11/9/2026 6:54 PM, Keith Thompson wrote:
    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:
    On Mon, 9 Nov 2026 06:00:40 -0500, James Kuyper wrote:
    I tend not to use unnecessary parentheses, and I know the grammar
    well enough to correctly identify them - but many people don't know
    the grammar that well, which might include the next person to
    maintain my code.

    Even if they havenrCOt committed the precedence table to memory, surely
    they have the ability to look things up online
    <https://en.cppreference.com/c/language/operator_precedence>.

    If someone has regular trouble with certain language features, why
    arenrCOt pages that clarify those very issues not already in their
    browser bookmarks?

    If I haven't memorized all the precedence levels, I greatly prefer
    an expression I can read at a glance to one that requires me to
    consult some document before I can be sure what it means, just so
    I can continue to the next line of code.

    Just one example: I couldn't tell you whether `^` or `|` binds more
    tightly without looking it up. If you can, that's great.

    Preferences for *how many* strictly semantically unnecessary
    parentheses are appropriate vary greatly, but few C programmers
    would insist on none.

    I ship my software written in four different software languages. C++, Fortran, Visual Basic, and C#. Remembering the nuances of each is
    tricky. I find it best to be safe.

    I have shipped software in about a dozen software languages in my 51
    year career. C++, Fortran IV (66), Fortran 77, Visual Basic, C#, Turbo Pascal, Basic, Turbo C, Unix C, IBM 370 Assembler, Intel x86 Assembler,
    AWK. I think that I am leaving out a couple that I cannot remember at
    the moment.

    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c++,comp.lang.c on Mon Nov 9 22:25:20 2026
    From Newsgroup: comp.lang.c

    On 11/9/2026 8:39 PM, Lynn McGuire wrote:
    On 11/9/2026 6:54 PM, Keith Thompson wrote:
    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:
    On Mon, 9 Nov 2026 06:00:40 -0500, James Kuyper wrote:
    I tend not to use unnecessary parentheses, and I know the grammar
    well enough to correctly identify them - but many people don't know
    the grammar that well, which might include the next person to
    maintain my code.

    Even if they havenrCOt committed the precedence table to memory, surely
    they have the ability to look things up online
    <https://en.cppreference.com/c/language/operator_precedence>.

    If someone has regular trouble with certain language features, why
    arenrCOt pages that clarify those very issues not already in their
    browser bookmarks?

    If I haven't memorized all the precedence levels, I greatly prefer
    an expression I can read at a glance to one that requires me to
    consult some document before I can be sure what it means, just so
    I can continue to the next line of code.

    Just one example: I couldn't tell you whether `^` or `|` binds more
    tightly without looking it up.-a If you can, that's great.

    Preferences for *how many* strictly semantically unnecessary
    parentheses are appropriate vary greatly, but few C programmers
    would insist on none.

    I ship my software written in four different software languages.-a C++, Fortran, Visual Basic, and C#.-a Remembering the nuances of each is tricky.-a I find it best to be safe.

    I have shipped software in about a dozen software languages in my 51
    year career.-a C++, Fortran IV (66), Fortran 77, Visual Basic,

    VB 6? Do you use access as well?

    C#, Turbo
    Pascal, Basic, Turbo C, Unix C, IBM 370 Assembler, Intel x86 Assembler, AWK.-a I think that I am leaving out a couple that I cannot remember at
    the moment.

    Lynn


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Tue Nov 10 08:36:02 2026
    From Newsgroup: comp.lang.c

    On 10/11/2026 01:54, Keith Thompson wrote:
    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:
    On Mon, 9 Nov 2026 06:00:40 -0500, James Kuyper wrote:
    I tend not to use unnecessary parentheses, and I know the grammar
    well enough to correctly identify them - but many people don't know
    the grammar that well, which might include the next person to
    maintain my code.

    Even if they havenrCOt committed the precedence table to memory, surely
    they have the ability to look things up online
    <https://en.cppreference.com/c/language/operator_precedence>.

    If someone has regular trouble with certain language features, why
    arenrCOt pages that clarify those very issues not already in their
    browser bookmarks?

    If I haven't memorized all the precedence levels, I greatly prefer
    an expression I can read at a glance to one that requires me to
    consult some document before I can be sure what it means, just so
    I can continue to the next line of code.

    Just one example: I couldn't tell you whether `^` or `|` binds more
    tightly without looking it up. If you can, that's great.

    Speaking as someone who uses the bit operations more than most
    programmers, I can't tell you that either - I use parentheses to make it clear. I have other things on which to use my limited brainpower!

    There are things that it is perhaps better not to know - because then
    you write your code in a clearer fashion that is obvious to experts and newcomers alike.

    (I am not necessarily talking about newcomers to C or C++ - people work
    with these languages in wildly different fields, and work on wildly
    different types of code and styles of coding.)


    Preferences for *how many* strictly semantically unnecessary
    parentheses are appropriate vary greatly, but few C programmers
    would insist on none.


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Fred. Zwarts@F.Zwarts@HetNet.nl to comp.lang.c++,comp.lang.c on Tue Nov 10 09:58:18 2026
    From Newsgroup: comp.lang.c

    Op 09.nov.2026 om 10:03 schreef Bonita Montero:
    Am 06.11.2026 um 00:42 schrieb Lynn McGuire:

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }
    ...
    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }
    The latter one leads to more optimized code !

    Really? Why?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Tue Nov 10 10:32:41 2026
    From Newsgroup: comp.lang.c

    On 10/11/2026 09:58, Fred. Zwarts wrote:
    Op 09.nov.2026 om 10:03 schreef Bonita Montero:
    Am 06.11.2026 um 00:42 schrieb Lynn McGuire:

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }
    ...
    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }
    The latter one leads to more optimized code !

    Really? Why?

    I /presume/ Bonita was joking.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From James Kuyper@jameskuyper@alumni.caltech.edu to comp.lang.c++,comp.lang.c on Tue Nov 10 10:45:08 2026
    From Newsgroup: comp.lang.c

    On 2026-11-09 15:42, Janis Papanagnou wrote:
    On 2026-11-09 12:00, James Kuyper wrote:
    I tend not to use unnecessary parentheses, and I know the grammar well
    enough to correctly identify them - but many people don't know the
    grammar that well, which might include the next person to maintain my
    code. There are reasonable arguments that I should use parentheses more
    than I actually do, for the benefit of such people.

    I'm "a bit" unsettled by the idea of a programmer who is unfamiliar
    with the language in general or the grammar specifically! (I know
    there's such folks writing programs.) I wouldn't write programs in
    ways to satisfy such folks. I'd certainly write programs in ways to
    keep the program maintainable focusing on the language specifics not imagining that the piece of code might be handled by a Neanderthal.

    I've worked with a lot of entry-level programmers in my career. Some of
    them had Ph.Ds in science, but were novices to programming. That
    probably influenced my expectations.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Bonita Montero@Bonita.Montero@gmail.com to comp.lang.c++,comp.lang.c on Tue Nov 10 17:41:44 2026
    From Newsgroup: comp.lang.c

    Am 10.11.2026 um 09:58 schrieb Fred. Zwarts:
    Op 09.nov.2026 om 10:03 schreef Bonita Montero:
    Am 06.11.2026 um 00:42 schrieb Lynn McGuire:

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }
    ...
    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }
    The latter one leads to more optimized code !

    Really? Why?

    It's faster the more braces you have.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Tue Nov 10 14:48:50 2026
    From Newsgroup: comp.lang.c

    On 11/10/2026 12:25 AM, Chris M. Thomasson wrote:
    On 11/9/2026 8:39 PM, Lynn McGuire wrote:
    On 11/9/2026 6:54 PM, Keith Thompson wrote:
    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:
    On Mon, 9 Nov 2026 06:00:40 -0500, James Kuyper wrote:
    I tend not to use unnecessary parentheses, and I know the grammar
    well enough to correctly identify them - but many people don't know
    the grammar that well, which might include the next person to
    maintain my code.

    Even if they havenrCOt committed the precedence table to memory, surely >>>> they have the ability to look things up online
    <https://en.cppreference.com/c/language/operator_precedence>.

    If someone has regular trouble with certain language features, why
    arenrCOt pages that clarify those very issues not already in their
    browser bookmarks?

    If I haven't memorized all the precedence levels, I greatly prefer
    an expression I can read at a glance to one that requires me to
    consult some document before I can be sure what it means, just so
    I can continue to the next line of code.

    Just one example: I couldn't tell you whether `^` or `|` binds more
    tightly without looking it up.-a If you can, that's great.

    Preferences for *how many* strictly semantically unnecessary
    parentheses are appropriate vary greatly, but few C programmers
    would insist on none.

    I ship my software written in four different software languages.-a C++,
    Fortran, Visual Basic, and C#.-a Remembering the nuances of each is
    tricky.-a I find it best to be safe.

    I have shipped software in about a dozen software languages in my 51
    year career.-a C++, Fortran IV (66), Fortran 77, Visual Basic,

    VB 6? Do you use access as well?

    C#, Turbo Pascal, Basic, Turbo C, Unix C, IBM 370 Assembler, Intel x86
    Assembler, AWK.-a I think that I am leaving out a couple that I cannot
    remember at the moment.

    Lynn

    Nope. It is just a sample app with source code to show how to connect
    to my DLLs using VB. I have several samples apps including an Excel spreadsheet. I have never used Access.

    All of my calculation software is currently Win32 DLLs so my customers
    can easily use them for custom calculations.

    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c++,comp.lang.c on Tue Nov 10 13:12:48 2026
    From Newsgroup: comp.lang.c

    On 11/10/2026 12:48 PM, Lynn McGuire wrote:
    On 11/10/2026 12:25 AM, Chris M. Thomasson wrote:
    On 11/9/2026 8:39 PM, Lynn McGuire wrote:
    On 11/9/2026 6:54 PM, Keith Thompson wrote:
    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:
    On Mon, 9 Nov 2026 06:00:40 -0500, James Kuyper wrote:
    I tend not to use unnecessary parentheses, and I know the grammar
    well enough to correctly identify them - but many people don't know >>>>>> the grammar that well, which might include the next person to
    maintain my code.

    Even if they havenrCOt committed the precedence table to memory, surely >>>>> they have the ability to look things up online
    <https://en.cppreference.com/c/language/operator_precedence>.

    If someone has regular trouble with certain language features, why
    arenrCOt pages that clarify those very issues not already in their
    browser bookmarks?

    If I haven't memorized all the precedence levels, I greatly prefer
    an expression I can read at a glance to one that requires me to
    consult some document before I can be sure what it means, just so
    I can continue to the next line of code.

    Just one example: I couldn't tell you whether `^` or `|` binds more
    tightly without looking it up.-a If you can, that's great.

    Preferences for *how many* strictly semantically unnecessary
    parentheses are appropriate vary greatly, but few C programmers
    would insist on none.

    I ship my software written in four different software languages.-a C+
    +, Fortran, Visual Basic, and C#.-a Remembering the nuances of each is
    tricky.-a I find it best to be safe.

    I have shipped software in about a dozen software languages in my 51
    year career.-a C++, Fortran IV (66), Fortran 77, Visual Basic,

    VB 6? Do you use access as well?

    C#, Turbo Pascal, Basic, Turbo C, Unix C, IBM 370 Assembler, Intel
    x86 Assembler, AWK.-a I think that I am leaving out a couple that I
    cannot remember at the moment.

    Lynn

    Nope.-a It is just a sample app with source code to show how to connect
    to my DLLs using VB.

    That's fine. Fwiw, I wrote a full blown specialized whole home/pool
    inspection system using VB 6, Access and Word 6 for my Dad way back in
    the day. What service pack are you using? Those were fun... ahh, back in
    the day... ;^o


    I have several samples apps including an Excel
    spreadsheet.-a I have never used Access.

    Actually, Access worked pretty damn good for my needs. Then, iirc, it
    got superseded by SQL server.


    All of my calculation software is currently Win32 DLLs so my customers
    can easily use them for custom calculations.

    Well, that should work fine. Once they know the API, anybody should be
    able to use them. Iirc, it was a little strange to map DLL's created in
    C to the VB 6 data types. But, can be done for sure.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++,comp.lang.c on Tue Nov 10 15:21:25 2026
    From Newsgroup: comp.lang.c

    On 11/10/2026 3:12 PM, Chris M. Thomasson wrote:
    On 11/10/2026 12:48 PM, Lynn McGuire wrote:
    On 11/10/2026 12:25 AM, Chris M. Thomasson wrote:
    On 11/9/2026 8:39 PM, Lynn McGuire wrote:
    On 11/9/2026 6:54 PM, Keith Thompson wrote:
    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:
    On Mon, 9 Nov 2026 06:00:40 -0500, James Kuyper wrote:
    I tend not to use unnecessary parentheses, and I know the grammar >>>>>>> well enough to correctly identify them - but many people don't know >>>>>>> the grammar that well, which might include the next person to
    maintain my code.

    Even if they havenrCOt committed the precedence table to memory, surely >>>>>> they have the ability to look things up online
    <https://en.cppreference.com/c/language/operator_precedence>.

    If someone has regular trouble with certain language features, why >>>>>> arenrCOt pages that clarify those very issues not already in their >>>>>> browser bookmarks?

    If I haven't memorized all the precedence levels, I greatly prefer
    an expression I can read at a glance to one that requires me to
    consult some document before I can be sure what it means, just so
    I can continue to the next line of code.

    Just one example: I couldn't tell you whether `^` or `|` binds more
    tightly without looking it up.-a If you can, that's great.

    Preferences for *how many* strictly semantically unnecessary
    parentheses are appropriate vary greatly, but few C programmers
    would insist on none.

    I ship my software written in four different software languages.-a C+ >>>> +, Fortran, Visual Basic, and C#.-a Remembering the nuances of each
    is tricky.-a I find it best to be safe.

    I have shipped software in about a dozen software languages in my 51
    year career.-a C++, Fortran IV (66), Fortran 77, Visual Basic,

    VB 6? Do you use access as well?

    C#, Turbo Pascal, Basic, Turbo C, Unix C, IBM 370 Assembler, Intel
    x86 Assembler, AWK.-a I think that I am leaving out a couple that I
    cannot remember at the moment.

    Lynn

    Nope.-a It is just a sample app with source code to show how to connect
    to my DLLs using VB.

    That's fine. Fwiw, I wrote a full blown specialized whole home/pool inspection system using VB 6, Access and Word 6 for my Dad way back in
    the day. What service pack are you using? Those were fun... ahh, back in
    the day... ;^o


    I have several samples apps including an Excel spreadsheet.-a I have
    never used Access.

    Actually, Access worked pretty damn good for my needs. Then, iirc, it
    got superseded by SQL server.


    All of my calculation software is currently Win32 DLLs so my customers
    can easily use them for custom calculations.

    Well, that should work fine. Once they know the API, anybody should be
    able to use them. Iirc, it was a little strange to map DLL's created in
    C to the VB 6 data types. But, can be done for sure.

    VB6 SP5 IIRC.

    Lynn

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c++,comp.lang.c on Tue Nov 10 13:23:20 2026
    From Newsgroup: comp.lang.c

    On 11/10/2026 8:41 AM, Bonita Montero wrote:
    Am 10.11.2026 um 09:58 schrieb Fred. Zwarts:
    Op 09.nov.2026 om 10:03 schreef Bonita Montero:
    Am 06.11.2026 um 00:42 schrieb Lynn McGuire:

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }
    ...
    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }
    The latter one leads to more optimized code !

    Really? Why?

    It's faster the more braces you have.

    You mean taking pressure off of the compiler stages, or what?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Wed Nov 11 08:38:41 2026
    From Newsgroup: comp.lang.c

    On 2026-11-10 22:23, Chris M. Thomasson wrote:
    On 11/10/2026 8:41 AM, Bonita Montero wrote:
    Am 10.11.2026 um 09:58 schrieb Fred. Zwarts:
    Op 09.nov.2026 om 10:03 schreef Bonita Montero:
    Am 06.11.2026 um 00:42 schrieb Lynn McGuire:

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }
    ...
    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }
    The latter one leads to more optimized code !

    Really? Why?

    It's faster the more braces you have.

    You mean taking pressure off of the compiler stages, or what?

    It's actually depending on the quotient of parenthesis and braces,
    just to be clear. If the number of braces is f(i) and the number
    of parenthesis is f(i+1), where 'f' is the Fibonacci function,
    the compiler will be able to create faster code, whereas if these
    numbers are swapped it will create slower code. (Obviously, no?)

    Janis

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Bonita Montero@Bonita.Montero@gmail.com to comp.lang.c++,comp.lang.c on Wed Nov 11 11:11:50 2026
    From Newsgroup: comp.lang.c

    Am 11.11.2026 um 08:38 schrieb Janis Papanagnou:

    It's actually depending on the quotient of parenthesis and braces,
    just to be clear. If the number of braces is f(i) and the number
    of parenthesis is f(i+1), where 'f' is the Fibonacci function,
    the compiler will be able to create faster code, whereas if these
    numbers are swapped it will create slower code. (Obviously, no?)
    Great !
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Tristan Wibberley@tristan.wibberley+netnews2@alumni.manchester.ac.uk to comp.lang.c++,comp.lang.c on Thu Nov 12 19:44:01 2026
    From Newsgroup: comp.lang.c

    On 06/11/2026 01:12, Lawrence DrCOOliveiro wrote:
    On Thu, 5 Nov 2026 19:52:31 -0500, James Kuyper wrote:

    For historical reasons, bitwise or (|) and bitwise and (&) are
    exceptions. Unfortunately, correcting that mistake would break
    backwards compatibility ...

    The only real issue is that bitwise ops have lower priority than
    comparisons, when they should be higher. If they were higher, then an expression like

    (bitval & mask) == desired_value



    wouldnrCOt need parentheses.

    Realistically, can anyone offer *any* real-world C code that
    uses an expression that would be parenthesized like

    a & (b == c)

    bitwise ops are well used to do logic on 'booleans' without increasing cyclomatic complexity which is very important for safety critical
    procedures, as long as you are very regular with how you evaluate
    expressions that produce them (I used it in very regular ways having
    decided it was okay but I here qualify myself in case some strange
    comparisons are not defined to evaluate to either 1 or 0 - "!!" can
    often and perhaps always be used).

    Both rhs and lhs are evaluated on each evaluation of the whole when '&'
    is used, but not when '&&' is used.

    I usually add parentheses anyway to these kinds of expressions, or
    better yet define a const register local object (which is often easier
    to follow in a debugger and to reference an intermediate result in
    extrinsic analysis). Helping the reader to know superficially what the
    meaning of such expression is lets them put more time elsewhere to
    achieve a purpose correctly.
    --
    Tristan Wibberley

    The message body is Copyright (C) 2026 Tristan Wibberley except
    citations and quotations noted. All Rights Reserved except that you may,
    of course, cite it academically giving credit to me, distribute it
    verbatim as part of a usenet system or its archives, and use it to
    promote my greatness and general superiority without misrepresentation
    of my opinions other than my opinion of my greatness and general
    superiority which you _may_ misrepresent. You definitely MAY NOT train
    any production AI system with it but you may train experimental AI that
    will only be used for evaluation of the AI methods it implements.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Tristan Wibberley@tristan.wibberley+netnews2@alumni.manchester.ac.uk to comp.lang.c++,comp.lang.c on Thu Nov 12 22:27:14 2026
    From Newsgroup: comp.lang.c

    On 12/11/2026 19:44, Tristan Wibberley wrote:
    On 06/11/2026 01:12, Lawrence DrCOOliveiro wrote:
    On Thu, 5 Nov 2026 19:52:31 -0500, James Kuyper wrote:

    For historical reasons, bitwise or (|) and bitwise and (&) are
    exceptions. Unfortunately, correcting that mistake would break
    backwards compatibility ...

    The only real issue is that bitwise ops have lower priority than
    comparisons, when they should be higher. If they were higher, then an
    expression like

    (bitval & mask) == desired_value



    wouldnrCOt need parentheses.

    Realistically, can anyone offer *any* real-world C code that
    uses an expression that would be parenthesized like

    a & (b == c)

    bitwise ops are well used to do logic on 'booleans'

    oh yeah, for C this is all "int" so I think I would only want to do it
    with 2s-complement architectures. I think C++ is fine because they're
    "bool" instead.
    --
    Tristan Wibberley

    The message body is Copyright (C) 2026 Tristan Wibberley except
    citations and quotations noted. All Rights Reserved except that you may,
    of course, cite it academically giving credit to me, distribute it
    verbatim as part of a usenet system or its archives, and use it to
    promote my greatness and general superiority without misrepresentation
    of my opinions other than my opinion of my greatness and general
    superiority which you _may_ misrepresent. You definitely MAY NOT train
    any production AI system with it but you may train experimental AI that
    will only be used for evaluation of the AI methods it implements.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Fri Nov 13 09:41:06 2026
    From Newsgroup: comp.lang.c

    On 12/11/2026 23:27, Tristan Wibberley wrote:
    On 12/11/2026 19:44, Tristan Wibberley wrote:
    On 06/11/2026 01:12, Lawrence DrCOOliveiro wrote:
    On Thu, 5 Nov 2026 19:52:31 -0500, James Kuyper wrote:

    For historical reasons, bitwise or (|) and bitwise and (&) are
    exceptions. Unfortunately, correcting that mistake would break
    backwards compatibility ...

    The only real issue is that bitwise ops have lower priority than
    comparisons, when they should be higher. If they were higher, then an
    expression like

    (bitval & mask) == desired_value



    wouldnrCOt need parentheses.

    Realistically, can anyone offer *any* real-world C code that
    uses an expression that would be parenthesized like

    a & (b == c)

    bitwise ops are well used to do logic on 'booleans'

    oh yeah, for C this is all "int" so I think I would only want to do it
    with 2s-complement architectures. I think C++ is fine because they're
    "bool" instead.



    In C, the equality and relational operators evaluate to an "int" value
    of either 0 or 1. They never result in any other value. In C++, the
    type of the evaluation is "bool", but the value is identical. Given
    that there are (in both languages) implicit conversions between bool and
    int and back again that will not affect these values at all, there is no practical difference unless you are using the type directly (for sizeof, _Generic, type inference, _Alignof).

    (Conversion to bool is done by comparing the value to 0. So any int
    value other than 0 gets converted to "true", while 0 gets converted to "false". Two logical negations - !!x - is sometimes used as a kind of "normalisation" operator that in C changes a non-zero scalar value -
    including non-null pointers - to an int of value 1, and changes a zero
    scalar value - including a null pointer - into an int of value 0. It is superfluous if "x" is the result of an equality or relational operator,
    since those already evaluate to 0 or 1.)

    When applied to values that are either 0 or 1, the bitwise operators &
    and | will give the same results as the logical operators && and ||.

    The bitwise operators will always result in code that acts as if it
    evaluates the right-hand side of the expression. The logical operators
    result in code that acts as if it evaluates the right-hand side if and
    only if the evaluation of the left-hand side does not determine the
    final evaluation.

    Note the "acts as if". If you write "if ((x > 2) && (x < 10))", the
    generated code will almost certainly be the same as if you used bitwise
    &, and both sub-expressions will be evaluated - because that is more
    efficient than using a conditional branch. The only time an optimising compiler actually follows the rules about what is and what is not
    evaluated, is when there are side-effects that could potentially lead to observable behaviour. Outside of that, the compiler will generate what
    it thinks is the most efficient result.

    The most sensible way to write your code - IMHO - is to use bitwise
    operators only when you actually mean bitwise operations such as
    masking. Use logical operators when you mean logical operations - "this
    is true AND that is true" or "this is true OR that is true". And of
    course, use logical operators if you need to rely on the short-circuit evaluation or order of evaluation.


    In terms of style, for complex expressions you should always use
    parentheses and/or split up the expression into parts assigned to local variables, according to what you think gives the clearest and most maintainable code that fits with any coding style requirements you have
    for the project, and perhaps with consideration for ease of debugging
    tools if that is relevant. Optimising compilers are likely to generate identical code regardless of how you split things up. There is nothing special about logical or bitwise operators here.

    And don't bother with the "register" keyword. Optimising compilers have ignored that for decades, and C++ removed it in C++17 (while preserving
    it as a keyword for future usage).


    None of this has any connection to the representation of signed
    integers, or whether that is two's complement or otherwise. No known
    modern C compilers (i.e., anything beyond perhaps C99) use anything
    other than two's complement - no known C++ compilers have ever supported anything else. Signed integer representation is always two's complement
    since C23 and C++20.


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From antispam@antispam@fricas.org (Waldek Hebisch) to comp.lang.c++,comp.lang.c on Fri Nov 13 14:47:49 2026
    From Newsgroup: comp.lang.c

    In comp.lang.c Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    On 2026-11-09 21:24, Lynn McGuire wrote:
    On 11/8/2026 2:55 AM, Janis Papanagnou wrote:
    On 2026-11-08 02:13, Lynn McGuire wrote:
    On 11/7/2026 6:30 PM, Janis Papanagnou wrote:
    [...]-a I'm still traumatized by the code
    that I had tried to de-goto-fy not long ago.

    At least I do not have any "come from"s in my code.

    :-)

    I suppose you have Intercal in mind? ;-)

    Fortran of course.
    -a-a https://en.wikipedia.org/wiki/COMEFROM

    Jesus! 8-o

    Interesting article; I didn't know that "joke" was
    considered also by those more serious languages.

    It is unfortunate that joke made people overlook potentially
    quite useful instruction. Let me add that I mean instruction
    at assembly/machine level (that is why I do not elaborate here,
    as this has nothing to do with C). In higher level languages it
    probably would interfere too much with semantics of other
    constructs to make sense.
    --
    Waldek Hebisch
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Tristan Wibberley@tristan.wibberley+netnews2@alumni.manchester.ac.uk to comp.lang.c++,comp.lang.c on Fri Nov 13 15:27:37 2026
    From Newsgroup: comp.lang.c

    On 13/11/2026 08:41, David Brown wrote:
    On 12/11/2026 23:27, Tristan Wibberley wrote:
    On 12/11/2026 19:44, Tristan Wibberley wrote:
    On 06/11/2026 01:12, Lawrence DrCOOliveiro wrote:
    On Thu, 5 Nov 2026 19:52:31 -0500, James Kuyper wrote:

    For historical reasons, bitwise or (|) and bitwise and (&) are
    exceptions. Unfortunately, correcting that mistake would break
    backwards compatibility ...

    The only real issue is that bitwise ops have lower priority than
    comparisons, when they should be higher. If they were higher, then an
    expression like

    -a-a-a-a (bitval & mask) == desired_value



    wouldnrCOt need parentheses.

    Realistically, can anyone offer *any* real-world C code that
    uses an expression that would be parenthesized like

    -a-a-a-a a & (b == c)

    bitwise ops are well used to do logic on 'booleans'

    oh yeah, for C this is all "int" so I think I would only want to do it
    with 2s-complement architectures. I think C++ is fine because they're
    "bool" instead.



    In C, the equality and relational operators evaluate to an "int" value
    of either 0 or 1.-a They never result in any other value.

    0 has two representations in 1s-complement, all zeros or all ones. I am
    worried about that when using bitwise operators to implement logic in
    case a comparison yields an all-ones representation of 0. Do comparisons
    and ! always produce the all-zeros representation in 1s-complement machines?


    The only time an optimising
    compiler actually follows the rules about what is and what is not
    evaluated, is when there are side-effects that could potentially lead to observable behaviour.

    For sufficiently restrictive definitions of "observable". Clocks and
    voltage drops are observable. Voltage drops in particular can cause
    explosives to land in the wrong place when other systems don't get the
    current they need. If you can supply the current without dropping
    voltage you still have more heat being produced. It all matters at the extremes.


    The most sensible way to write your code - IMHO - is to use bitwise
    operators only when you actually mean bitwise operations such as
    masking.-a Use logical operators when you mean logical operations - "this
    is true AND that is true" or "this is true OR that is true".-a And of
    course, use logical operators if you need to rely on the short-circuit evaluation or order of evaluation.

    Using shortcutting when you don't require shortcutting has a meaningful
    effect on objective measures of the complexity of the system (as does
    using an unspecified order with bitwise operators.

    bitwise operators always evaluate both operands but in unspecified order. logical operators sometimes evaluate only one operand but in specified
    order when they evaluate both.

    The types of failure that can be caused by that difference can matter.

    Using the bitwise operators can cause usage of shared resources to vary
    across the domain. Idempotency mitigates this and is advisable widely
    anyway, so for techniques to avoid shared resources from existing
    anyway. The integration solutions for such problems are some of the
    intuitive ones relied on when integrating independent active systems
    anyway (ie, we already think about systems in terms of "the two effects
    happen, make sure your stuff works in case of whichever order"). One can
    signal an effect threshold wrapping the logic in a trigger call and so
    forth.

    Using the logical operators can cause usage of private resources to vary
    across the domain. It remains a problem even when other good practices
    have been applied.

    It's not perfect to use bitwise, clearly, but the alternative complexity
    of a configuration (order vs shortcut) is sometimes an opportune
    reduction in complexity of a development process or asset lifetime.


    And don't bother with the "register" keyword.-a Optimising compilers have ignored that for decades, and C++ removed it in C++17 (while preserving
    it as a keyword for future usage).

    It ought to have been kept meaningful in C++ to mask operator& at least.
    I recall it was at least as early as C++98 that it was noneffective,
    definitely I know it was before C++17 because I never used C++17.
    --
    Tristan Wibberley

    The message body is Copyright (C) 2026 Tristan Wibberley except
    citations and quotations noted. All Rights Reserved except that you may,
    of course, cite it academically giving credit to me, distribute it
    verbatim as part of a usenet system or its archives, and use it to
    promote my greatness and general superiority without misrepresentation
    of my opinions other than my opinion of my greatness and general
    superiority which you _may_ misrepresent. You definitely MAY NOT train
    any production AI system with it but you may train experimental AI that
    will only be used for evaluation of the AI methods it implements.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Fri Nov 13 17:49:00 2026
    From Newsgroup: comp.lang.c

    On 13/11/2026 16:27, Tristan Wibberley wrote:
    On 13/11/2026 08:41, David Brown wrote:
    On 12/11/2026 23:27, Tristan Wibberley wrote:
    On 12/11/2026 19:44, Tristan Wibberley wrote:
    On 06/11/2026 01:12, Lawrence DrCOOliveiro wrote:
    On Thu, 5 Nov 2026 19:52:31 -0500, James Kuyper wrote:

    For historical reasons, bitwise or (|) and bitwise and (&) are
    exceptions. Unfortunately, correcting that mistake would break
    backwards compatibility ...

    The only real issue is that bitwise ops have lower priority than
    comparisons, when they should be higher. If they were higher, then an >>>>> expression like

    -a-a-a-a (bitval & mask) == desired_value



    wouldnrCOt need parentheses.

    Realistically, can anyone offer *any* real-world C code that
    uses an expression that would be parenthesized like

    -a-a-a-a a & (b == c)

    bitwise ops are well used to do logic on 'booleans'

    oh yeah, for C this is all "int" so I think I would only want to do it
    with 2s-complement architectures. I think C++ is fine because they're
    "bool" instead.



    In C, the equality and relational operators evaluate to an "int" value
    of either 0 or 1.-a They never result in any other value.

    0 has two representations in 1s-complement, all zeros or all ones. I am worried about that when using bitwise operators to implement logic in
    case a comparison yields an all-ones representation of 0. Do comparisons
    and ! always produce the all-zeros representation in 1s-complement machines?


    In C implementations using ones' complement, the two representations of integer value 0 (if all one bits is considered a value rather than a
    trap representation) always compare equal. There are only a few
    operations that can potentially produce a negative zero, and the
    relational operators are not amongst those. Bitwise operators /can/
    produce a negative zero, but you would have to start off with negative
    numbers to get them - an expression mixing relational operators and
    bitwise operators (other than bitwise negation) cannot produce anything
    other than 0 or 1.

    And there are no C implementations that are not two's complement, other
    than a few ancient compilers for museum mainframes. You can be entirely confident that your code will never be used on them.

    But as I said before, if you are writing a logical expression, use the
    logical operators. There is no benefit in using bitwise operators when
    the logical operators are appropriate - unless you count "confusing
    readers" as a benefit.


    The only time an optimising
    compiler actually follows the rules about what is and what is not
    evaluated, is when there are side-effects that could potentially lead to
    observable behaviour.

    For sufficiently restrictive definitions of "observable".

    The C standards define "observable behaviour", and that is the
    definition I use.

    Clocks and
    voltage drops are observable. Voltage drops in particular can cause explosives to land in the wrong place when other systems don't get the current they need. If you can supply the current without dropping
    voltage you still have more heat being produced. It all matters at the extremes.

    Lots of things matter in real-world programming other than "observable behaviour" in C code. But it is only the C standards definition of "observable behaviour" that matters for the semantics of the C code, or
    how the compiler looks at it. When choosing whether or not to evaluate
    the right-hand side of an operator expression, the compiler cares about
    what the C standards say - not any non-C effects. And if the compiler
    can see that it has a choice in how to generate the code, it will pick
    based on flags for speed optimisation, size optimisation, debugging, etc.



    The most sensible way to write your code - IMHO - is to use bitwise
    operators only when you actually mean bitwise operations such as
    masking.-a Use logical operators when you mean logical operations - "this
    is true AND that is true" or "this is true OR that is true".-a And of
    course, use logical operators if you need to rely on the short-circuit
    evaluation or order of evaluation.

    Using shortcutting when you don't require shortcutting has a meaningful effect on objective measures of the complexity of the system (as does
    using an unspecified order with bitwise operators.

    What meaningful effect? The evaluation of an expression that does not
    affect C observable behaviour has /zero/ "meaningful effect" in C.

    First understand the C semantics - what the C code means, and what the
    "as if" rule means. That's how you can understand what "correctness"
    means in C programming. C has no concept of speed, or code size, or
    suchlike. Only once you have got that under control can you start
    looking at non-C attributes, like code speed. The speed of code can of
    course be a vital element in the usefulness of a program for a given
    task, but it is pointless to worry about speed until you know what is
    correct or not. Fast but wrong is no use to anyone.


    bitwise operators always evaluate both operands but in unspecified order.

    Correct.

    logical operators sometimes evaluate only one operand but in specified
    order when they evaluate both.

    Correct.

    But do you understand what "evaluates" means here?

    Look at the generated code for simple test code :

    <https://godbolt.org/z/9Wxsheqhd>

    int test1(int x) {
    return (x > 2) && (x < 10);
    }

    int test2(int x) {
    return (x > 2) & (x < 10);
    }


    It test1, the semantics of C require that the generated code acts /as
    if/ the second test "x < 10" is evaluated if and only if the first test
    "x > 2" passes. And yet the compiler generates identical code for both
    test1 and test2. It does this because evaluating "x < 10" has no side-effects, and the most efficient results are produced by doing that calculation every time.


    The types of failure that can be caused by that difference can matter.

    Do you have an example in mind? That might make it easier to understand
    what you are talking about.



    Using the bitwise operators can cause usage of shared resources to vary across the domain.

    I have no idea what you mean by this.

    Idempotency mitigates this and is advisable widely
    anyway, so for techniques to avoid shared resources from existing
    anyway.

    I have no idea what you mean by this. You might be using the word "idempotency" incorrectly. (An operation "op" is "idempotent" if and
    only if "x op x == x" for all "x".)

    The integration solutions for such problems are some of the
    intuitive ones relied on when integrating independent active systems
    anyway (ie, we already think about systems in terms of "the two effects happen, make sure your stuff works in case of whichever order").

    Are you trying to say that since the order of evaluation of the sub-expressions for most operators (including the bitwise ones) is not specified, your code should not rely on any specific ordering? That is obviously true.

    One can
    signal an effect threshold wrapping the logic in a trigger call and so
    forth.

    Again, I have no idea what you are trying to say here.



    Using the logical operators can cause usage of private resources to vary across the domain. It remains a problem even when other good practices
    have been applied.

    You are going to have to give examples or explain better. The only
    thing I can think of is for cryptography applications where you want to
    be sure that timings, processor power usage, and other related factors
    are independent of the values being used. To give a simplistic example,
    you don't want to have a password check algorithm that returns a failure
    as soon as it hits a mismatched character - then an attacker could use
    that information to know which character was incorrect. In general, C
    has no way to express things like constant timings - cryptographic
    algorithms that need that cannot be written in standard C.


    It's not perfect to use bitwise, clearly, but the alternative complexity
    of a configuration (order vs shortcut) is sometimes an opportune
    reduction in complexity of a development process or asset lifetime.


    And don't bother with the "register" keyword.-a Optimising compilers have
    ignored that for decades, and C++ removed it in C++17 (while preserving
    it as a keyword for future usage).

    It ought to have been kept meaningful in C++ to mask operator& at least.
    I recall it was at least as early as C++98 that it was noneffective, definitely I know it was before C++17 because I never used C++17.


    Prior to C++17, the "register" keyword had the same meaning in C++ as it
    does in C. It is a storage-class specified. The only semantic effect
    of declaring an object with "register" is that it is a constraint
    violation to apply the & operator to it - i.e., you cannot take its
    address. It may be seen as a hint to the compiler that the variable
    should be optimised for speed - but optimising compilers have ignored
    that for decades, since they optimise /everything/. It may have some
    small influence on some compilers if you do not use optimisation, but it
    is meaningless to be concerned about the speed of code when not optimising.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c++,comp.lang.c on Fri Nov 13 11:46:09 2026
    From Newsgroup: comp.lang.c

    Tristan Wibberley <tristan.wibberley+netnews2@alumni.manchester.ac.uk>
    writes:
    On 13/11/2026 08:41, David Brown wrote:
    [...]
    In C, the equality and relational operators evaluate to an "int" value
    of either 0 or 1.-a They never result in any other value.

    0 has two representations in 1s-complement, all zeros or all ones. I am worried about that when using bitwise operators to implement logic in
    case a comparison yields an all-ones representation of 0. Do comparisons
    and ! always produce the all-zeros representation in 1s-complement machines?

    C17 6.2.6.2p3,4:

    If the implementation supports negative zeros, they shall be
    generated only by:

    -- the &, |, ^, ~, <<, and >> operators with operands that
    produce such a value;

    -- the +, - , *, /, and % operators where one operand is a negative
    zero and the result is zero;

    -- compound assignment operators based on the above cases.

    It is unspecified whether these cases actually generate a negative
    zero or a normal zero, and whether a negative zero becomes a normal
    zero when stored in an object.

    If the implementation does not support negative zeros, the behavior
    of the &, |, ^, ~, <<, and >> operators with operands that would
    produce such a value is undefined.

    So the equality and comparison operators never yield a negative zero.

    C23 drops this and requires 2's-complement.

    You are extremely unlikely to encounter a pre-C23 C implementation that
    doesn't use 2's-complement.

    [...]

    And don't bother with the "register" keyword.-a Optimising compilers have
    ignored that for decades, and C++ removed it in C++17 (while preserving
    it as a keyword for future usage).

    It ought to have been kept meaningful in C++ to mask operator& at least.
    I recall it was at least as early as C++98 that it was noneffective, definitely I know it was before C++17 because I never used C++17.

    I've never had a need to disable unary &. Have you?
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Tristan Wibberley@tristan.wibberley+netnews2@alumni.manchester.ac.uk to comp.lang.c++,comp.lang.c on Fri Nov 13 21:33:36 2026
    From Newsgroup: comp.lang.c

    On 13/11/2026 19:46, Keith Thompson wrote:
    Tristan Wibberley <tristan.wibberley+netnews2@alumni.manchester.ac.uk> writes:
    On 13/11/2026 08:41, David Brown wrote:
    [...]
    In C, the equality and relational operators evaluate to an "int" value
    of either 0 or 1.-a They never result in any other value.

    0 has two representations in 1s-complement, all zeros or all ones. I am
    worried about that when using bitwise operators to implement logic in
    case a comparison yields an all-ones representation of 0. Do comparisons
    and ! always produce the all-zeros representation in 1s-complement machines?

    C17 6.2.6.2p3,4:

    ...

    So the equality and comparison operators never yield a negative zero.

    Thanks I should have taken the time to read a published final draft.


    And don't bother with the "register" keyword.-a Optimising compilers have >>> ignored that for decades, and C++ removed it in C++17 (while preserving
    it as a keyword for future usage).

    It ought to have been kept meaningful in C++ to mask operator& at least.
    I recall it was at least as early as C++98 that it was noneffective,
    definitely I know it was before C++17 because I never used C++17.

    I've never had a need to disable unary &. Have you?

    I've had situations that would be benefitted by it, eliminating various opportunities can make some code simpler.
    --
    Tristan Wibberley

    The message body is Copyright (C) 2026 Tristan Wibberley except
    citations and quotations noted. All Rights Reserved except that you may,
    of course, cite it academically giving credit to me, distribute it
    verbatim as part of a usenet system or its archives, and use it to
    promote my greatness and general superiority without misrepresentation
    of my opinions other than my opinion of my greatness and general
    superiority which you _may_ misrepresent. You definitely MAY NOT train
    any production AI system with it but you may train experimental AI that
    will only be used for evaluation of the AI methods it implements.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Tristan Wibberley@tristan.wibberley+netnews2@alumni.manchester.ac.uk to comp.lang.c++,comp.lang.c on Fri Nov 13 22:21:12 2026
    From Newsgroup: comp.lang.c

    On 13/11/2026 16:49, David Brown wrote:
    On 13/11/2026 16:27, Tristan Wibberley wrote:
    On 13/11/2026 08:41, David Brown wrote:
    On 12/11/2026 23:27, Tristan Wibberley wrote:
    On 12/11/2026 19:44, Tristan Wibberley wrote:
    On 06/11/2026 01:12, Lawrence DrCOOliveiro wrote:

    There is no benefit in using bitwise operators when
    the logical operators are appropriate - unless you count "confusing
    readers" as a benefit.

    That's definitely not true, being able to know both lhs and rhs are
    evaluated regardless of the value of the other from just a glance at the
    code is beneficial. Begin able to know that, when they're function
    calls, side-effects of both will occur is beneficial.


    The only time an optimising
    compiler actually follows the rules about what is and what is not
    evaluated, is when there are side-effects that could potentially lead to >>> observable behaviour.

    For sufficiently restrictive definitions of "observable".

    The C standards define "observable behaviour", and that is the
    definition I use.

    Noted for this occasion, I will forget that you're using it in future.


    The most sensible way to write your code - IMHO - is to use bitwise
    operators only when you actually mean bitwise operations such as
    masking.

    For this purpose, they actually are logical too, one of the bits
    nominated by the implementation has the required meaning. It is
    commonplace to do this when two or more dimensions are involved, this is
    merely extending the practice down to when just one dimension is involved.


    Using shortcutting when you don't require shortcutting has a meaningful
    effect on objective measures of the complexity of the system (as does
    using an unspecified order with bitwise operators.

    What meaningful effect?-a The evaluation of an expression that does not affect C observable behaviour has /zero/ "meaningful effect" in C.

    Meaningful effect "on objective measures of the complexity of the
    system". shortcutting increases cyclomatic complexity which is often
    considered a cost.


    But do you understand what "evaluates" means here?

    Yes. in great detail.


    The types of failure that can be caused by that difference can matter.

    Do you have an example in mind?-a That might make it easier to understand what you are talking about.

    Yes but I'm feeling pretty tired. You will know what kinds of problems
    can occur in a system containing a C program among its constituents
    based on orderings of effects or based on conditional effects.



    Using the bitwise operators can cause usage of shared resources to vary
    across the domain.

    I have no idea what you mean by this.

    Different cases of a function's inputs could make a resource that both
    operands manipulate change in ways that are described non-uniformly
    across cases, extrapolation from test cases to all other cases to
    predict compliance can be wrong.


    Idempotency mitigates this and is advisable widely
    anyway, so for techniques to avoid shared resources from existing
    anyway.

    I have no idea what you mean by this.-a You might be using the word "idempotency" incorrectly.-a (An operation "op" is "idempotent" if and
    only if "x op x == x" for all "x".)

    I understand the term to be used slightly more broadly but only
    slightly. What I had in mind is only irrelevantly different from your definition.

    many classes of invalid programs caused by being affected by ordering
    can be made valid by using idempotency in their side-effects.

    Then I meant "also for techniques..." which are such a big group that
    I'm not going to bother giving examples because this has started to feel
    like a job interview which I do not want.


    The integration solutions for such problems are some of the
    intuitive ones relied on when integrating independent active systems
    anyway (ie, we already think about systems in terms of "the two effects
    happen, make sure your stuff works in case of whichever order").

    Are you trying to say that since the order of evaluation of the sub- expressions for most operators (including the bitwise ones) is not
    specified, your code should not rely on any specific ordering?-a That is obviously true.

    I'm saying we make systems that do not rely on ordering all the time and
    the management of a development process involving just more of the same
    is easiest.


    One can
    signal an effect threshold wrapping the logic in a trigger call and so
    forth.

    Again, I have no idea what you are trying to say here.

    One can call a finalisation function after the conditions have been
    evaluated which delimits a segment of program addresses in which some
    signal is permissibly invalid. That can include I/O so that external
    signals are issued.




    Using the logical operators can cause usage of private resources to vary
    across the domain. It remains a problem even when other good practices
    have been applied.

    You are going to have to give examples or explain better.

    Different cases of a function's inputs could make a resource that the
    rhs manipulates change in ways that are described non-uniformly across
    cases, extrapolation from test cases to all other cases to predict
    compliance can be wrong.

    Matters of ordering are experienced through systems at all scales and
    are solved with a few practices all over all the systems, in particular, systems are very commonly composed of parts that act independently
    except when explicitly excluding each other by signalling protocols (or
    by a scheduler or broker). Matters of shortcutting are different so
    those very common practices don't all apply helpfully, making
    shortcutting, in my mind, a choice to make very cautiously.
    --
    Tristan Wibberley

    The message body is Copyright (C) 2026 Tristan Wibberley except
    citations and quotations noted. All Rights Reserved except that you may,
    of course, cite it academically giving credit to me, distribute it
    verbatim as part of a usenet system or its archives, and use it to
    promote my greatness and general superiority without misrepresentation
    of my opinions other than my opinion of my greatness and general
    superiority which you _may_ misrepresent. You definitely MAY NOT train
    any production AI system with it but you may train experimental AI that
    will only be used for evaluation of the AI methods it implements.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Tristan Wibberley@tristan.wibberley+netnews2@alumni.manchester.ac.uk to comp.lang.c++,comp.lang.c on Sat Nov 14 19:05:51 2026
    From Newsgroup: comp.lang.c

    On 06/11/2026 15:33, James Kuyper wrote:
    On 2026-11-06 00:35, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]
    Otherwise, one or more parentheses
    might solve the problem.

    Technically correct (the best kind of correct), but *two* or more
    parentheses are even better.
    I should have said "... one or more matched pairs of parentheses ...".


    You have clearly suffered the pedants more than one man should have to
    bear. I feel for you.
    --
    Tristan Wibberley

    The message body is Copyright (C) 2026 Tristan Wibberley except
    citations and quotations noted. All Rights Reserved except that you may,
    of course, cite it academically giving credit to me, distribute it
    verbatim as part of a usenet system or its archives, and use it to
    promote my greatness and general superiority without misrepresentation
    of my opinions other than my opinion of my greatness and general
    superiority which you _may_ misrepresent. You definitely MAY NOT train
    any production AI system with it but you may train experimental AI that
    will only be used for evaluation of the AI methods it implements.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Tristan Wibberley@tristan.wibberley+netnews2@alumni.manchester.ac.uk to comp.lang.c++,comp.lang.c on Sat Nov 14 19:07:13 2026
    From Newsgroup: comp.lang.c

    On 10/11/2026 16:41, Bonita Montero wrote:
    Am 10.11.2026 um 09:58 schrieb Fred. Zwarts:
    Op 09.nov.2026 om 10:03 schreef Bonita Montero:
    Am 06.11.2026 um 00:42 schrieb Lynn McGuire:

    if (j1 * i1 < 1) {
    -a-a-a-a goto L463;
    }
    ...
    if ((j1 * i1) < 1) {
    -a-a-a-a goto L463;
    }
    The latter one leads to more optimized code !

    Really? Why?

    It's faster the more braces you have.

    They're the go-faster stripes of programming. That's why LISP is so fast.
    --
    Tristan Wibberley

    The message body is Copyright (C) 2026 Tristan Wibberley except
    citations and quotations noted. All Rights Reserved except that you may,
    of course, cite it academically giving credit to me, distribute it
    verbatim as part of a usenet system or its archives, and use it to
    promote my greatness and general superiority without misrepresentation
    of my opinions other than my opinion of my greatness and general
    superiority which you _may_ misrepresent. You definitely MAY NOT train
    any production AI system with it but you may train experimental AI that
    will only be used for evaluation of the AI methods it implements.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From James Kuyper@jameskuyper@alumni.caltech.edu to comp.lang.c++,comp.lang.c on Sat Nov 14 20:52:56 2026
    From Newsgroup: comp.lang.c

    On 2026-11-14 14:05, Tristan Wibberley wrote:
    On 06/11/2026 15:33, James Kuyper wrote:
    On 2026-11-06 00:35, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]
    Otherwise, one or more parentheses
    might solve the problem.

    Technically correct (the best kind of correct), but *two* or more
    parentheses are even better.
    I should have said "... one or more matched pairs of parentheses ...".


    You have clearly suffered the pedants more than one man should have to
    bear. I feel for you.
    I am one of the worst pedants you're likely to meet. I cannot object to
    such minor pedantry.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c++,comp.lang.c on Sat Nov 14 18:22:38 2026
    From Newsgroup: comp.lang.c

    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    On 2026-11-14 14:05, Tristan Wibberley wrote:
    On 06/11/2026 15:33, James Kuyper wrote:
    On 2026-11-06 00:35, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]
    Otherwise, one or more parentheses
    might solve the problem.

    Technically correct (the best kind of correct), but *two* or more
    parentheses are even better.

    I should have said "... one or more matched pairs of parentheses ...".

    You have clearly suffered the pedants more than one man should have to
    bear. I feel for you.

    I am one of the worst pedants you're likely to meet. I cannot object to
    such minor pedantry.

    Pedants unite!

    And my remark was intended mostly for humorous effect. (Hoping
    this doesn't start a debate about whether it was funny.)
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Sun Nov 15 04:28:24 2026
    From Newsgroup: comp.lang.c

    On 2026-11-15 03:22, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    On 2026-11-14 14:05, Tristan Wibberley wrote:
    On 06/11/2026 15:33, James Kuyper wrote:
    On 2026-11-06 00:35, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]
    Otherwise, one or more parentheses >>>>>> might solve the problem.

    Technically correct (the best kind of correct), but *two* or more
    parentheses are even better.

    I should have said "... one or more matched pairs of parentheses ...".

    You have clearly suffered the pedants more than one man should have to
    bear. I feel for you.

    I am one of the worst pedants you're likely to meet. I cannot object to
    such minor pedantry.

    :-)

    Pedants unite!

    Ped-ants un-ite.

    Did it occur to you that "ped" is a Latin prefix for "foot", that
    "ants" are insects with many feet, and "ite" in Latin means "go!",
    and I wonder why there's the "un" prefix that negates "un-ite" as
    "Don't go!". Probably a hidden request to not use "Go" as language
    but rather focus on "C" here?!


    And my remark was intended mostly for humorous effect.

    Please abstain from all humorous statements! - Note: "We [...] do
    not have a sense of humor we're aware of." (You know the quote!?)

    (Hoping this doesn't start a debate about whether it was funny.)

    Oops! - You failed in a way. - Oh, "a way"; we *go* on a way. -
    I suspect a conspiracy to subvert the purpose of this newsgroup!

    Janis

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Sun Nov 15 13:09:14 2026
    From Newsgroup: comp.lang.c

    On 13/11/2026 23:21, Tristan Wibberley wrote:
    On 13/11/2026 16:49, David Brown wrote:
    On 13/11/2026 16:27, Tristan Wibberley wrote:
    On 13/11/2026 08:41, David Brown wrote:
    On 12/11/2026 23:27, Tristan Wibberley wrote:
    On 12/11/2026 19:44, Tristan Wibberley wrote:
    On 06/11/2026 01:12, Lawrence DrCOOliveiro wrote:

    There is no benefit in using bitwise operators when
    the logical operators are appropriate - unless you count "confusing
    readers" as a benefit.

    That's definitely not true, being able to know both lhs and rhs are
    evaluated regardless of the value of the other from just a glance at the
    code is beneficial. Begin able to know that, when they're function
    calls, side-effects of both will occur is beneficial.


    As I said, there is no benefit in using bitwise operators when logical operators are appropriate. If you are relying on the evaluation of "B"
    in the expression "A op B", then using logical operators would not be appropriate.

    But I think it could be considered bad style, and potentially confusing,
    if you wrote "success = foo() & bar();" where these two functions
    returned pass / fail indications and you used this formulation to say
    that both had to be run, with "success" being the conjunction. It would
    be more idiomatic, I think, to call them separately. With bitwise and
    here, readers would wonder if you had really meant to use logical and.

    The details of the rest of the code, the names of the functions, and so
    on, would of course greatly influence how readers would interpret the
    code. But my feeling is that when a reader sees at a glance the bitwise
    and operator between two function calls, they would not immediately
    conclude that you used bitwise and so that the rhs was also evaluated -
    they would guess that you made a mistake in the code.



    The only time an optimising
    compiler actually follows the rules about what is and what is not
    evaluated, is when there are side-effects that could potentially lead to >>>> observable behaviour.

    For sufficiently restrictive definitions of "observable".

    The C standards define "observable behaviour", and that is the
    definition I use.

    Noted for this occasion, I will forget that you're using it in future.


    I can try and remember to make it clearer in the future. But since this
    is comp.lang.c and comp.lang.c++, and "observable behaviour" is a very specific term from the standards that is critical to understanding the semantics of these languages, I think you should get used to the term.
    The word "behaviour" on its own is likely to be used more generally.


    The most sensible way to write your code - IMHO - is to use bitwise
    operators only when you actually mean bitwise operations such as
    masking.

    For this purpose, they actually are logical too, one of the bits
    nominated by the implementation has the required meaning. It is
    commonplace to do this when two or more dimensions are involved, this is merely extending the practice down to when just one dimension is involved.


    You can certainly use the bitwise operators to have the same effect
    effect as the logical operators (apart from evaluation guarantees), in
    the same way that you can write "x + x + x" instead of "x * 3" - using
    the addition operator to do multiplication. In general, I don't think
    it is a good idea, even though compilers will often generate identical
    code. You would even get the same results replacing "&&" with "*", but
    that would be even less of a good idea.


    Using shortcutting when you don't require shortcutting has a meaningful
    effect on objective measures of the complexity of the system (as does
    using an unspecified order with bitwise operators.

    What meaningful effect?-a The evaluation of an expression that does not
    affect C observable behaviour has /zero/ "meaningful effect" in C.

    Meaningful effect "on objective measures of the complexity of the
    system". shortcutting increases cyclomatic complexity which is often considered a cost.


    Okay, I can see that :

    // success = foo() && bar()
    bool success = foo();
    if (success) {
    success = bar();
    }

    // success = foo() & bar()
    bool success_foo = foo();
    bool success_bar = bar();
    bool success = success_foo & success_bar;

    Yes, the conditional increases the cyclomatic complexity of the code.
    But while cyclomatic complexity can sometimes be a useful and measurable metric, I am not at all convinced that it is often a particularly useful
    one except if you need to give an objective reason why a particular bad function is "clearly incomprehensible".


    But do you understand what "evaluates" means here?

    Yes. in great detail.


    The types of failure that can be caused by that difference can matter.

    Do you have an example in mind?-a That might make it easier to understand
    what you are talking about.

    Yes but I'm feeling pretty tired. You will know what kinds of problems
    can occur in a system containing a C program among its constituents
    based on orderings of effects or based on conditional effects.


    Fair enough. It means that I am sticking to "foo() & bar()" examples,
    which might not match what you are thinking about.

    Note that when you write "foo() & bar()", where these are both function
    calls, you are guaranteed that either "far()" is evaluated first and
    then "bar()" is evaluated, or vice-versa. You have no control over
    their order of evaluation. And if these are not function calls, but are
    other kinds of sub-expressions (or perhaps macros), their evaluation can
    be interleaved.

    If you need to control the order of evaluation and side-effects, you
    should do so with separate statements. Call "foo" first in one
    statement, then call "bar".



    Using the bitwise operators can cause usage of shared resources to vary
    across the domain.

    I have no idea what you mean by this.

    Different cases of a function's inputs could make a resource that both operands manipulate change in ways that are described non-uniformly
    across cases, extrapolation from test cases to all other cases to
    predict compliance can be wrong.


    I still fail to see a relevancy. If you can give an example, great. If
    not, I will leave it.


    Idempotency mitigates this and is advisable widely
    anyway, so for techniques to avoid shared resources from existing
    anyway.

    I have no idea what you mean by this.-a You might be using the word
    "idempotency" incorrectly.-a (An operation "op" is "idempotent" if and
    only if "x op x == x" for all "x".)

    I understand the term to be used slightly more broadly but only
    slightly. What I had in mind is only irrelevantly different from your definition.


    Its definition can certainly be broadened beyond just binary operators,
    but I agree that would not be relevant.

    many classes of invalid programs caused by being affected by ordering
    can be made valid by using idempotency in their side-effects.

    For example :

    bool initialised;
    void initialise() {
    // Do useful stuff
    initialised = true;
    }

    bool foo() {
    if (!initialised) initialise();
    return do_foo();
    }

    bool bar() {
    if (!initialised) initialise();
    return do_bar();
    }

    Then it does not matter which of "foo" and "bar" is called first in
    "foo() & bar()", because they are "idempotent" in ensuring that the initialisation is done correctly. Is this what you are talking about?

    The "static initialisation order fiasco" is a real thing, and programs
    have had bugs from getting this kind of thing wrong. But I can't see
    its relevance in the choice of using bitwise & for logical operations.


    Then I meant "also for techniques..." which are such a big group that
    I'm not going to bother giving examples because this has started to feel
    like a job interview which I do not want.

    I am just trying to understand your perspective, that's all. There is
    no job at the end of it, and no pressure for you to write more than you
    want to. Discussing how and why people write code in different ways can
    teach us new ways to write code, or give better appreciation for why
    people write or interpret code differently.



    The integration solutions for such problems are some of the
    intuitive ones relied on when integrating independent active systems
    anyway (ie, we already think about systems in terms of "the two effects
    happen, make sure your stuff works in case of whichever order").

    Are you trying to say that since the order of evaluation of the sub-
    expressions for most operators (including the bitwise ones) is not
    specified, your code should not rely on any specific ordering?-a That is
    obviously true.

    I'm saying we make systems that do not rely on ordering all the time and
    the management of a development process involving just more of the same
    is easiest.


    One can
    signal an effect threshold wrapping the logic in a trigger call and so
    forth.

    Again, I have no idea what you are trying to say here.

    One can call a finalisation function after the conditions have been
    evaluated which delimits a segment of program addresses in which some
    signal is permissibly invalid. That can include I/O so that external
    signals are issued.




    Using the logical operators can cause usage of private resources to vary >>> across the domain. It remains a problem even when other good practices
    have been applied.

    You are going to have to give examples or explain better.

    Different cases of a function's inputs could make a resource that the
    rhs manipulates change in ways that are described non-uniformly across
    cases, extrapolation from test cases to all other cases to predict
    compliance can be wrong.

    Matters of ordering are experienced through systems at all scales and
    are solved with a few practices all over all the systems, in particular, systems are very commonly composed of parts that act independently
    except when explicitly excluding each other by signalling protocols (or
    by a scheduler or broker). Matters of shortcutting are different so
    those very common practices don't all apply helpfully, making
    shortcutting, in my mind, a choice to make very cautiously.



    When you write code in C or C++, you control the order of observable
    behaviour (as defined by the standards). You don't control any other
    order, you don't control any timing, and you don't control when the compiler-generated code does extra work, or skips work, if the work does
    not influence observable behaviour.

    You should not use && if you want the observable behaviour from the rhs regardless of the value of the lhs. That's not special about
    shortcutting logical operators, that's just writing code that does what
    you want it to do. Similarly, you should not use & for logical
    conjunction if you /do/ want shortcutting semantics.

    But IMHO you should not use bitwise & when your code is expressing a
    logical intent - just as you should not use "int" when you mean "bool".
    That is not directly a matter of code correctness, but it is a matter of
    code style and unambiguous understanding from both readers and writers,
    and thus a reduction of the risk of bugs.

    It is also very common in coding standards to say that statements should
    do one thing at a time. Such rules would ban "foo() & bar()" and also
    "foo() && bar()" when both functions may have side-effects. Follow that
    rule, and there is no risk due to the unspecified order of evaluation,
    nor any need to be concerned about "idempotency".

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Tristan Wibberley@tristan.wibberley+netnews2@alumni.manchester.ac.uk to comp.lang.c++,comp.lang.c on Sun Nov 15 20:14:27 2026
    From Newsgroup: comp.lang.c

    On 15/11/2026 02:22, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    On 2026-11-14 14:05, Tristan Wibberley wrote:
    On 06/11/2026 15:33, James Kuyper wrote:
    On 2026-11-06 00:35, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]
    Otherwise, one or more parentheses >>>>>> might solve the problem.

    Technically correct (the best kind of correct), but *two* or more
    parentheses are even better.

    I should have said "... one or more matched pairs of parentheses ...".

    You have clearly suffered the pedants more than one man should have to
    bear. I feel for you.

    I am one of the worst pedants you're likely to meet. I cannot object to
    such minor pedantry.

    Pedants unite!

    And my remark was intended mostly for humorous effect. (Hoping
    this doesn't start a debate about whether it was funny.)


    In nerd voice "Err, technically, according to ISO humour standard
    10101010101, it was funny but not comical"
    --
    Tristan Wibberley

    The message body is Copyright (C) 2026 Tristan Wibberley except
    citations and quotations noted. All Rights Reserved except that you may,
    of course, cite it academically giving credit to me, distribute it
    verbatim as part of a usenet system or its archives, and use it to
    promote my greatness and general superiority without misrepresentation
    of my opinions other than my opinion of my greatness and general
    superiority which you _may_ misrepresent. You definitely MAY NOT train
    any production AI system with it but you may train experimental AI that
    will only be used for evaluation of the AI methods it implements.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Mon Nov 16 09:50:04 2026
    From Newsgroup: comp.lang.c

    On 15/11/2026 04:28, Janis Papanagnou wrote:
    On 2026-11-15 03:22, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    On 2026-11-14 14:05, Tristan Wibberley wrote:
    On 06/11/2026 15:33, James Kuyper wrote:
    On 2026-11-06 00:35, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]
    -a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a Otherwise, one or more parentheses
    might solve the problem.

    Technically correct (the best kind of correct), but *two* or more
    parentheses are even better.

    I should have said "... one or more matched pairs of parentheses ...". >>>>
    You have clearly suffered the pedants more than one man should have to >>>> bear. I feel for you.

    I am one of the worst pedants you're likely to meet. I cannot object to
    such minor pedantry.

    :-)

    Pedants unite!

    Ped-ants un-ite.

    Did it occur to you that "ped" is a Latin prefix for "foot", that
    "ants" are insects with many feet, and "ite" in Latin means "go!",
    and I wonder why there's the "un" prefix that negates "un-ite" as
    "Don't go!". Probably a hidden request to not use "Go" as language
    but rather focus on "C" here?!


    I'm taking James' claim as a challenge! A /real/ pedant would know that
    "ped" is from the /Greek/ word for "child". The etymology of "pedant"
    is an old word for "schoolmaster" or "teacher" (specifically of
    children). :-)


    And my remark was intended mostly for humorous effect.

    Please abstain from all humorous statements! - Note: "We [...] do
    not have a sense of humor we're aware of." (You know the quote!?)

    Is it from the USA airport security guard training manual?

    (Yes, I know it is from a film, but I can't quite place it at the moment.)


    (Hoping this doesn't start a debate about whether it was funny.)

    /I/ thought it was amusing. But maybe I have a weird sense of humour.
    I am Scottish, after all, and in Scottish humour the smiley's are often
    bigger when they are well-hidden.


    Oops! - You failed in a way. - Oh, "a way"; we *go* on a way. -
    I suspect a conspiracy to subvert the purpose of this newsgroup!

    Doesn't it have to be hidden to be a conspiracy? Some people have been
    very open about trying to spoil the group!


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c++,comp.lang.c on Mon Nov 16 10:18:38 2026
    From Newsgroup: comp.lang.c

    On 2026-11-16 09:50, David Brown wrote:
    On 15/11/2026 04:28, Janis Papanagnou wrote:

    Ped-ants un-ite.

    Did it occur to you that "ped" is a Latin prefix for "foot", that
    "ants" are insects with many feet, and "ite" in Latin means "go!",
    and I wonder why there's the "un" prefix that negates "un-ite" as
    "Don't go!". Probably a hidden request to not use "Go" as language
    but rather focus on "C" here?!


    I'm taking James' claim as a challenge!-a A /real/ pedant would know that "ped" is from the /Greek/ word for "child".-a The etymology of "pedant"
    is an old word for "schoolmaster" or "teacher" (specifically of
    children).-a :-)

    Ah, it serves me right.

    What do I know about Greek. Latin is already demanding enough. :-)


    [...] "We [...] do not have a sense of humor we're aware of." [...]

    Is it from the USA airport security guard training manual?

    (Ouch, yes. - Probably not only in the US. Strange people/processes.)


    (Yes, I know it is from a film, but I can't quite place it at the moment.)

    Men in Black. (The agents visiting a lady frustrated by the police,
    and Tommy Lee Jones saying that.)

    [...]
    I suspect a conspiracy to subvert the purpose of this newsgroup!

    Doesn't it have to be hidden to be a conspiracy?-a [...]

    I thought it had been quite hidden and it got revealed?

    Now, unrevealed, the presumed conspiracy theory became a "fact". ;-)

    Janis

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Ross Finlayson@ross.a.finlayson@gmail.com to comp.lang.c++,comp.lang.c on Mon Nov 16 02:21:38 2026
    From Newsgroup: comp.lang.c

    On 11/15/2026 04:09 AM, David Brown wrote:
    On 13/11/2026 23:21, Tristan Wibberley wrote:
    On 13/11/2026 16:49, David Brown wrote:
    On 13/11/2026 16:27, Tristan Wibberley wrote:
    On 13/11/2026 08:41, David Brown wrote:
    On 12/11/2026 23:27, Tristan Wibberley wrote:
    On 12/11/2026 19:44, Tristan Wibberley wrote:
    On 06/11/2026 01:12, Lawrence DrCOOliveiro wrote:

    There is no benefit in using bitwise operators when
    the logical operators are appropriate - unless you count "confusing
    readers" as a benefit.

    That's definitely not true, being able to know both lhs and rhs are
    evaluated regardless of the value of the other from just a glance at the
    code is beneficial. Begin able to know that, when they're function
    calls, side-effects of both will occur is beneficial.


    As I said, there is no benefit in using bitwise operators when logical operators are appropriate. If you are relying on the evaluation of "B"
    in the expression "A op B", then using logical operators would not be appropriate.

    But I think it could be considered bad style, and potentially confusing,
    if you wrote "success = foo() & bar();" where these two functions
    returned pass / fail indications and you used this formulation to say
    that both had to be run, with "success" being the conjunction. It would
    be more idiomatic, I think, to call them separately. With bitwise and
    here, readers would wonder if you had really meant to use logical and.

    The details of the rest of the code, the names of the functions, and so
    on, would of course greatly influence how readers would interpret the
    code. But my feeling is that when a reader sees at a glance the bitwise
    and operator between two function calls, they would not immediately
    conclude that you used bitwise and so that the rhs was also evaluated -
    they would guess that you made a mistake in the code.



    The only time an optimising
    compiler actually follows the rules about what is and what is not
    evaluated, is when there are side-effects that could potentially
    lead to
    observable behaviour.

    For sufficiently restrictive definitions of "observable".

    The C standards define "observable behaviour", and that is the
    definition I use.

    Noted for this occasion, I will forget that you're using it in future.


    I can try and remember to make it clearer in the future. But since this
    is comp.lang.c and comp.lang.c++, and "observable behaviour" is a very specific term from the standards that is critical to understanding the semantics of these languages, I think you should get used to the term.
    The word "behaviour" on its own is likely to be used more generally.


    The most sensible way to write your code - IMHO - is to use bitwise
    operators only when you actually mean bitwise operations such as
    masking.

    For this purpose, they actually are logical too, one of the bits
    nominated by the implementation has the required meaning. It is
    commonplace to do this when two or more dimensions are involved, this is
    merely extending the practice down to when just one dimension is
    involved.


    You can certainly use the bitwise operators to have the same effect
    effect as the logical operators (apart from evaluation guarantees), in
    the same way that you can write "x + x + x" instead of "x * 3" - using
    the addition operator to do multiplication. In general, I don't think
    it is a good idea, even though compilers will often generate identical
    code. You would even get the same results replacing "&&" with "*", but
    that would be even less of a good idea.


    Using shortcutting when you don't require shortcutting has a meaningful >>>> effect on objective measures of the complexity of the system (as does
    using an unspecified order with bitwise operators.

    What meaningful effect? The evaluation of an expression that does not
    affect C observable behaviour has /zero/ "meaningful effect" in C.

    Meaningful effect "on objective measures of the complexity of the
    system". shortcutting increases cyclomatic complexity which is often
    considered a cost.


    Okay, I can see that :

    // success = foo() && bar()
    bool success = foo();
    if (success) {
    success = bar();
    }

    // success = foo() & bar()
    bool success_foo = foo();
    bool success_bar = bar();
    bool success = success_foo & success_bar;

    Yes, the conditional increases the cyclomatic complexity of the code.
    But while cyclomatic complexity can sometimes be a useful and measurable metric, I am not at all convinced that it is often a particularly useful
    one except if you need to give an objective reason why a particular bad function is "clearly incomprehensible".


    But do you understand what "evaluates" means here?

    Yes. in great detail.


    The types of failure that can be caused by that difference can matter.

    Do you have an example in mind? That might make it easier to understand >>> what you are talking about.

    Yes but I'm feeling pretty tired. You will know what kinds of problems
    can occur in a system containing a C program among its constituents
    based on orderings of effects or based on conditional effects.


    Fair enough. It means that I am sticking to "foo() & bar()" examples,
    which might not match what you are thinking about.

    Note that when you write "foo() & bar()", where these are both function calls, you are guaranteed that either "far()" is evaluated first and
    then "bar()" is evaluated, or vice-versa. You have no control over
    their order of evaluation. And if these are not function calls, but are other kinds of sub-expressions (or perhaps macros), their evaluation can
    be interleaved.

    If you need to control the order of evaluation and side-effects, you
    should do so with separate statements. Call "foo" first in one
    statement, then call "bar".



    Using the bitwise operators can cause usage of shared resources to vary >>>> across the domain.

    I have no idea what you mean by this.

    Different cases of a function's inputs could make a resource that both
    operands manipulate change in ways that are described non-uniformly
    across cases, extrapolation from test cases to all other cases to
    predict compliance can be wrong.


    I still fail to see a relevancy. If you can give an example, great. If
    not, I will leave it.


    Idempotency mitigates this and is advisable widely
    anyway, so for techniques to avoid shared resources from existing
    anyway.

    I have no idea what you mean by this. You might be using the word
    "idempotency" incorrectly. (An operation "op" is "idempotent" if and
    only if "x op x == x" for all "x".)

    I understand the term to be used slightly more broadly but only
    slightly. What I had in mind is only irrelevantly different from your
    definition.


    Its definition can certainly be broadened beyond just binary operators,
    but I agree that would not be relevant.

    many classes of invalid programs caused by being affected by ordering
    can be made valid by using idempotency in their side-effects.

    For example :

    bool initialised;
    void initialise() {
    // Do useful stuff
    initialised = true;
    }

    bool foo() {
    if (!initialised) initialise();
    return do_foo();
    }

    bool bar() {
    if (!initialised) initialise();
    return do_bar();
    }

    Then it does not matter which of "foo" and "bar" is called first in
    "foo() & bar()", because they are "idempotent" in ensuring that the initialisation is done correctly. Is this what you are talking about?

    The "static initialisation order fiasco" is a real thing, and programs
    have had bugs from getting this kind of thing wrong. But I can't see
    its relevance in the choice of using bitwise & for logical operations.


    Then I meant "also for techniques..." which are such a big group that
    I'm not going to bother giving examples because this has started to feel
    like a job interview which I do not want.

    I am just trying to understand your perspective, that's all. There is
    no job at the end of it, and no pressure for you to write more than you
    want to. Discussing how and why people write code in different ways can teach us new ways to write code, or give better appreciation for why
    people write or interpret code differently.



    The integration solutions for such problems are some of the
    intuitive ones relied on when integrating independent active systems
    anyway (ie, we already think about systems in terms of "the two effects >>>> happen, make sure your stuff works in case of whichever order").

    Are you trying to say that since the order of evaluation of the sub-
    expressions for most operators (including the bitwise ones) is not
    specified, your code should not rely on any specific ordering? That is
    obviously true.

    I'm saying we make systems that do not rely on ordering all the time and
    the management of a development process involving just more of the same
    is easiest.


    One can
    signal an effect threshold wrapping the logic in a trigger call and so >>>> forth.

    Again, I have no idea what you are trying to say here.

    One can call a finalisation function after the conditions have been
    evaluated which delimits a segment of program addresses in which some
    signal is permissibly invalid. That can include I/O so that external
    signals are issued.




    Using the logical operators can cause usage of private resources to
    vary
    across the domain. It remains a problem even when other good practices >>>> have been applied.

    You are going to have to give examples or explain better.

    Different cases of a function's inputs could make a resource that the
    rhs manipulates change in ways that are described non-uniformly across
    cases, extrapolation from test cases to all other cases to predict
    compliance can be wrong.

    Matters of ordering are experienced through systems at all scales and
    are solved with a few practices all over all the systems, in particular,
    systems are very commonly composed of parts that act independently
    except when explicitly excluding each other by signalling protocols (or
    by a scheduler or broker). Matters of shortcutting are different so
    those very common practices don't all apply helpfully, making
    shortcutting, in my mind, a choice to make very cautiously.



    When you write code in C or C++, you control the order of observable behaviour (as defined by the standards). You don't control any other
    order, you don't control any timing, and you don't control when the compiler-generated code does extra work, or skips work, if the work does
    not influence observable behaviour.

    You should not use && if you want the observable behaviour from the rhs regardless of the value of the lhs. That's not special about
    shortcutting logical operators, that's just writing code that does what
    you want it to do. Similarly, you should not use & for logical
    conjunction if you /do/ want shortcutting semantics.

    But IMHO you should not use bitwise & when your code is expressing a
    logical intent - just as you should not use "int" when you mean "bool".
    That is not directly a matter of code correctness, but it is a matter of
    code style and unambiguous understanding from both readers and writers,
    and thus a reduction of the risk of bugs.

    It is also very common in coding standards to say that statements should
    do one thing at a time. Such rules would ban "foo() & bar()" and also
    "foo() && bar()" when both functions may have side-effects. Follow that rule, and there is no risk due to the unspecified order of evaluation,
    nor any need to be concerned about "idempotency".



    One way to read what your saying is "algebraizations" and
    "arithmetizations", that's the act of interpreting models of
    objects their matters of relation according to the matters of
    relation of algebras and arithmetic.

    It's totally usual for example with model of "machine" integers
    and "machine" arithmetic that being a bounded sort of version
    of "natural" integers and "natural" arithmetic, counts or tallies
    of things like counters or accumulators according to operations
    of arithmetic models of counts of things (which are models of
    relations of objects, generally enough, "the things").

    Then where for example "== is an operator", it results Boolean
    algebras and bit-wise predication Boolean lattices, algebraizations.


    It's totally similar with for example operations on formal words
    from formal languages like "+" for "concatenation". "Model theory
    is as model theory does."


    Then AND OR XOT NOT or bit-wise "arithmetic", is sort of about
    lattices of algebras, about that algebras aren't necessarily
    arithmetic, then that making vector of those is sort of attaining
    to "geometrization", or, also algebras of algebras, or sometimes
    called "magmas", that "magmas" are a bit looser definition inclusive
    of "algebras", which already are pretty loose since for example
    "semi-simple" or "non-commutative" groups and the like, divergent from arithmetic.



    So, one can define interpretation of the operations where the
    language makes for overloading operators any way you want,
    which may make sense when it models natural operations that
    happen to stand in as modeling algebras for example arithmetic,
    then though that just using arithmetic and machine integers
    as the model itself, also requires that it is what it is.

    Then "enum" is another usual sort of example, like for "un_set,
    un_legal, un_known", reserved values, where reserved values
    are another sort of account, like: "Not-A-Number".

    Machine integers can't quite achieve all of arithmetic themselves,
    while yet there are algebras & magmas of anything.


    There's a great book "Data Logic" from the 1970's I found one
    day in the university library stacks somewhere in Q section,
    been looking for that for a while, and it has lots of great
    accounts of data and the logic.



    "1's and 0's versus true and false?" Why lose, ....



    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Ross Finlayson@ross.a.finlayson@gmail.com to comp.lang.c++,comp.lang.c on Mon Nov 16 02:27:16 2026
    From Newsgroup: comp.lang.c

    On 11/16/2026 01:18 AM, Janis Papanagnou wrote:
    On 2026-11-16 09:50, David Brown wrote:
    On 15/11/2026 04:28, Janis Papanagnou wrote:

    Ped-ants un-ite.

    Did it occur to you that "ped" is a Latin prefix for "foot", that
    "ants" are insects with many feet, and "ite" in Latin means "go!",
    and I wonder why there's the "un" prefix that negates "un-ite" as
    "Don't go!". Probably a hidden request to not use "Go" as language
    but rather focus on "C" here?!


    I'm taking James' claim as a challenge! A /real/ pedant would know
    that "ped" is from the /Greek/ word for "child". The etymology of
    "pedant" is an old word for "schoolmaster" or "teacher" (specifically
    of children). :-)

    Ah, it serves me right.

    What do I know about Greek. Latin is already demanding enough. :-)


    [...] "We [...] do not have a sense of humor we're aware of." [...]

    Is it from the USA airport security guard training manual?

    (Ouch, yes. - Probably not only in the US. Strange people/processes.)


    (Yes, I know it is from a film, but I can't quite place it at the
    moment.)

    Men in Black. (The agents visiting a lady frustrated by the police,
    and Tommy Lee Jones saying that.)

    [...]
    I suspect a conspiracy to subvert the purpose of this newsgroup!

    Doesn't it have to be hidden to be a conspiracy? [...]

    I thought it had been quite hidden and it got revealed?

    Now, unrevealed, the presumed conspiracy theory became a "fact". ;-)

    Janis


    Same root, was "knee-high" vis-a-vis "ankle-biters".


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Mon Nov 16 12:37:53 2026
    From Newsgroup: comp.lang.c

    On 16/11/2026 11:21, Ross Finlayson wrote:

    One way to read what your saying is "algebraizations" and
    "arithmetizations", that's the act of interpreting models of
    objects their matters of relation according to the matters of
    relation of algebras and arithmetic.

    No, that is not a way to read what I wrote. I wrote in English.

    Please find some way to write comprehensibly, without the waffling and rambling, and focusing on the point you are trying to make.

    Maybe you could try this for a plan. Before hitting "send" on a post,
    give the post to your favourite AI slopbot and ask it to generate a
    single paragraph summary. If that summary does not match what you
    wanted to say, you know you need to express your post differently. And
    if it /does/ match what you want to say, just post that summary so that
    other people don't need to wade through your original post.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Mon Nov 16 12:43:16 2026
    From Newsgroup: comp.lang.c

    On 16/11/2026 10:18, Janis Papanagnou wrote:
    On 2026-11-16 09:50, David Brown wrote:
    On 15/11/2026 04:28, Janis Papanagnou wrote:

    Ped-ants un-ite.

    Did it occur to you that "ped" is a Latin prefix for "foot", that
    "ants" are insects with many feet, and "ite" in Latin means "go!",
    and I wonder why there's the "un" prefix that negates "un-ite" as
    "Don't go!". Probably a hidden request to not use "Go" as language
    but rather focus on "C" here?!


    I'm taking James' claim as a challenge!-a A /real/ pedant would know
    that "ped" is from the /Greek/ word for "child".-a The etymology of
    "pedant" is an old word for "schoolmaster" or "teacher" (specifically
    of children).-a :-)

    Ah, it serves me right.

    As we all know, Usenet is a place to learn new things!


    What do I know about Greek. Latin is already demanding enough. :-)

    For much of the Roman empire, Latin was the language of the plebs - the educated upper classes all spoke Greek. (Their schoolteachers - their
    pedants - were mostly Greek slaves.)



    [...] "We [...] do not have a sense of humor we're aware of." [...]

    Is it from the USA airport security guard training manual?

    (Ouch, yes. - Probably not only in the US. Strange people/processes.)


    (Yes, I know it is from a film, but I can't quite place it at the
    moment.)

    Men in Black. (The agents visiting a lady frustrated by the police,
    and Tommy Lee Jones saying that.)


    That's the one, yes.

    [...]
    I suspect a conspiracy to subvert the purpose of this newsgroup!

    Doesn't it have to be hidden to be a conspiracy?-a [...]

    I thought it had been quite hidden and it got revealed?

    Now, unrevealed, the presumed conspiracy theory became a "fact". ;-)

    What if it starts unrevealed, and then becomes a conspiracy theory -
    like the "fact" that birds don't exist?



    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Ross Finlayson@ross.a.finlayson@gmail.com to comp.lang.c++,comp.lang.c on Mon Nov 16 03:57:30 2026
    From Newsgroup: comp.lang.c

    On 11/16/2026 03:37 AM, David Brown wrote:
    On 16/11/2026 11:21, Ross Finlayson wrote:

    One way to read what your saying is "algebraizations" and
    "arithmetizations", that's the act of interpreting models of
    objects their matters of relation according to the matters of
    relation of algebras and arithmetic.

    No, that is not a way to read what I wrote. I wrote in English.

    Please find some way to write comprehensibly, without the waffling and rambling, and focusing on the point you are trying to make.

    Maybe you could try this for a plan. Before hitting "send" on a post,
    give the post to your favourite AI slopbot and ask it to generate a
    single paragraph summary. If that summary does not match what you
    wanted to say, you know you need to express your post differently. And
    if it /does/ match what you want to say, just post that summary so that
    other people don't need to wade through your original post.


    I dispute your estimation of my command of English.

    Wherever you got the impression that what I write
    isn't perfectly grammatical, if long-winded and
    for some a bit the too run-on the style, forget it.

    Of course above where I wrote "your" for "you're",
    that's intolerable.


    Once I asked one of those "on-line grade estimators"
    a sample of writing. This is where, for example,
    editors of things like newspapers would be aware
    of things like "news articles are written toa 6'th
    grade reading level".

    It said "Grade 26". Maybe it's the reading not
    the writing the problem.

    I will not insult your intelligence by insulting
    your intelligence by insulting your intelligence.


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Ross Finlayson@ross.a.finlayson@gmail.com to comp.lang.c++,comp.lang.c on Mon Nov 16 04:37:48 2026
    From Newsgroup: comp.lang.c

    On 11/16/2026 03:57 AM, Ross Finlayson wrote:
    On 11/16/2026 03:37 AM, David Brown wrote:
    On 16/11/2026 11:21, Ross Finlayson wrote:

    One way to read what your saying is "algebraizations" and
    "arithmetizations", that's the act of interpreting models of
    objects their matters of relation according to the matters of
    relation of algebras and arithmetic.

    No, that is not a way to read what I wrote. I wrote in English.

    Please find some way to write comprehensibly, without the waffling and
    rambling, and focusing on the point you are trying to make.

    Maybe you could try this for a plan. Before hitting "send" on a post,
    give the post to your favourite AI slopbot and ask it to generate a
    single paragraph summary. If that summary does not match what you
    wanted to say, you know you need to express your post differently. And
    if it /does/ match what you want to say, just post that summary so that
    other people don't need to wade through your original post.


    I dispute your estimation of my command of English.

    Wherever you got the impression that what I write
    isn't perfectly grammatical, if long-winded and
    for some a bit the too run-on the style, forget it.

    Of course above where I wrote "your" for "you're",
    that's intolerable.


    Once I asked one of those "on-line grade estimators"
    a sample of writing. This is where, for example,
    editors of things like newspapers would be aware
    of things like "news articles are written toa 6'th
    grade reading level".

    It said "Grade 26". Maybe it's the reading not
    the writing the problem.

    I will not insult your intelligence by insulting
    your intelligence by insulting your intelligence.




    So, back to "algebraizations" and "arithmetizations",
    then of course there's no end of accounts of applying
    algebraizations by modeling arithmetizations, or,
    overloading operations.

    Then if you'll excuse me, your perhaps constructive
    criticism, repeated insertedly, was not well-received,
    though of course you're welcome to your own opinion.


    The Japanese have a saying, now it's in English,
    "If you believe everything you read: maybe you shouldn't."


    Now if you'll excuse me I'll putter off.



    The "magma-oriented programming" then is rather sort
    of like when there's a hammer and things look like nails,
    "when all there is is slop, all you need is a mop".

    Magma-Oriented Programming


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.c++,comp.lang.c on Mon Nov 16 15:04:51 2026
    From Newsgroup: comp.lang.c

    On 16/11/2026 12:57, Ross Finlayson wrote:
    On 11/16/2026 03:37 AM, David Brown wrote:
    On 16/11/2026 11:21, Ross Finlayson wrote:

    One way to read what your saying is "algebraizations" and
    "arithmetizations", that's the act of interpreting models of
    objects their matters of relation according to the matters of
    relation of algebras and arithmetic.

    No, that is not a way to read what I wrote.-a I wrote in English.

    Please find some way to write comprehensibly, without the waffling and
    rambling, and focusing on the point you are trying to make.

    Maybe you could try this for a plan.-a Before hitting "send" on a post,
    give the post to your favourite AI slopbot and ask it to generate a
    single paragraph summary.-a If that summary does not match what you
    wanted to say, you know you need to express your post differently.-a And
    if it /does/ match what you want to say, just post that summary so that
    other people don't need to wade through your original post.


    I dispute your estimation of my command of English.

    Wherever you got the impression that what I write
    isn't perfectly grammatical, if long-winded and
    for some a bit the too run-on the style, forget it.

    Of course above where I wrote "your" for "you're",
    that's intolerable.


    Your grammar is imperfect, but not nearly bad enough to be an issue.
    Real problems include your regular use of words and phrases in a way
    that simply does not match their meaning. Run-on sentences are bad when
    they are too frequent, but made much worse by your overuse of "filler"
    words and phrases. Much of what you write would be more appropriate for
    a politician giving a filibuster speech.

    The root problem, I think, is that you have no focus in your writing.
    There is an open conduct between your thoughts and the words you type.
    Your thoughts wander, and - like everyone else - /you/ understand what
    you are thinking about. But other people do not live in your head. If
    you want people to understand what you are thinking about, you have to
    write in a way that other people can understand it - not just throw your thoughts at a page randomly.

    I believe you have things worth saying. That's why I am trying to
    suggest how you can improve your communication skills. Many others just
    write your posts off as "gobbledegook" or ignore them entirely. (The
    number of people that have given such feedback should be an indication
    that the problem here is the writer, not the readers.)

    This will, I think, be the last post I make directly to you (at least
    for a while) - unless you specifically ask for something. If you
    understand what I am trying to say, and appreciate that you have a
    serious problem communicating, then you can do something about it. If
    you don't think that is the case, then you will continue to write posts
    that are mostly ignored because they are simply too much effort to read.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Tim Rentsch@tr.17687@z991.linuxsc.com to comp.lang.c on Mon Nov 16 06:18:49 2026
    From Newsgroup: comp.lang.c

    Ross Finlayson <ross.a.finlayson@gmail.com> writes:

    [suggestions for writing improvement]

    I dispute your estimation of my command of English.

    The question here isn't your command of English.
    It's the quality of the writing. Or the lack
    thereof.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Ross Finlayson@ross.a.finlayson@gmail.com to comp.lang.c++,comp.lang.c on Mon Nov 16 08:33:01 2026
    From Newsgroup: comp.lang.c

    On 11/16/2026 06:04 AM, David Brown wrote:
    On 16/11/2026 12:57, Ross Finlayson wrote:
    On 11/16/2026 03:37 AM, David Brown wrote:
    On 16/11/2026 11:21, Ross Finlayson wrote:

    One way to read what your saying is "algebraizations" and
    "arithmetizations", that's the act of interpreting models of
    objects their matters of relation according to the matters of
    relation of algebras and arithmetic.

    No, that is not a way to read what I wrote. I wrote in English.

    Please find some way to write comprehensibly, without the waffling and
    rambling, and focusing on the point you are trying to make.

    Maybe you could try this for a plan. Before hitting "send" on a post,
    give the post to your favourite AI slopbot and ask it to generate a
    single paragraph summary. If that summary does not match what you
    wanted to say, you know you need to express your post differently. And
    if it /does/ match what you want to say, just post that summary so that
    other people don't need to wade through your original post.


    I dispute your estimation of my command of English.

    Wherever you got the impression that what I write
    isn't perfectly grammatical, if long-winded and
    for some a bit the too run-on the style, forget it.

    Of course above where I wrote "your" for "you're",
    that's intolerable.


    Your grammar is imperfect, but not nearly bad enough to be an issue.
    Real problems include your regular use of words and phrases in a way
    that simply does not match their meaning. Run-on sentences are bad when
    they are too frequent, but made much worse by your overuse of "filler"
    words and phrases. Much of what you write would be more appropriate for
    a politician giving a filibuster speech.

    The root problem, I think, is that you have no focus in your writing.
    There is an open conduct between your thoughts and the words you type.
    Your thoughts wander, and - like everyone else - /you/ understand what
    you are thinking about. But other people do not live in your head. If
    you want people to understand what you are thinking about, you have to
    write in a way that other people can understand it - not just throw your thoughts at a page randomly.

    I believe you have things worth saying. That's why I am trying to
    suggest how you can improve your communication skills. Many others just write your posts off as "gobbledegook" or ignore them entirely. (The
    number of people that have given such feedback should be an indication
    that the problem here is the writer, not the readers.)

    This will, I think, be the last post I make directly to you (at least
    for a while) - unless you specifically ask for something. If you
    understand what I am trying to say, and appreciate that you have a
    serious problem communicating, then you can do something about it. If
    you don't think that is the case, then you will continue to write posts
    that are mostly ignored because they are simply too much effort to read.



    Hm. Why, then, thank you good sir, such constructive criticism is
    estimated a fair and forthright or the conscientious opinion.

    That said, I'll yet aver that my command of the concepts is
    very strong, and it's toward, for example, "Grice", "Grice's maxims",
    of communication, or for example typical accounts of, "effective communication", vis-a-vis ethos and pathos and kairos here the _logos_,
    and not mambly-pambly sorts manager-speak, nor "control freaks",
    I'll aver that the more you know the better it goes.


    Thanks for writing.

    If I may, I'd then ask "are there any questions or perceived
    paradoxes or estimated particulars of incorrectness that it
    may help to clarify?"


    Some people prefer questions or the pointed, others a sort
    of tendered reserve, implying invitation to remarks, then
    as to whether, if I suggest that I _would_ ask, is that asking?


    That said, then in an obligatory manner about logical statement
    and parenthesis, has that precedence is most commonly C and C++'s
    vis-a-vis, for example Java's _few_ differences in precedence
    of priority of evaluation of operators their expressions in expressions,
    and never hurts, except for readability when
    it's obvious both the intent and the meaning.


    --- Synchronet 3.22a-Linux NewsLink 1.2