• Re: question about linker

    From James Kuyper@jameskuyper@alumni.caltech.edu to comp.lang.c on Wed Dec 18 16:04:06 2024
    From Newsgroup: comp.lang.c

    On 12/12/24 06:38, Janis Papanagnou wrote:
    On 12.12.2024 06:35, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    [...]
    For (yet another) example; my K&R shows a syntax for expressions like

    expression := binary
    binary := binary + binary
    binary := binary * binary

    That's odd. Is that an exact quotation?

    No, not exact, I abbreviated it; omitted about 25 other operators and
    used another syntax (no ' | '). (Trust me that it hasn't things that
    I called 'factor' and 'term' in my post, which is equivalent to what
    you have formulated below in your copy.) - I'm using a translation of something that someone classified as being a "pre-second" edition but
    not quite the first edition. Two references point to 1977 (Prentice
    Hall) and 1978 (Bell Labs). - The text for the "binary" syntax has two optional informal columns, the first one has the comment "precedence"
    for some of the variants of "binary" operators. (But it's also just
    titled as "Syntax in Short"; probably presented in a form to make it
    easy to understand without overloading it for purpose of a textbook.)
    It serves the purpose to explain an ambiguous syntax with non-codified precedence and a separate precedence table (but it's not an exact "C"
    syntax description as you'd probably find it in standards documents).

    My copy of K&R 1st edition has nothing remotely resembling that. I
    cannot find "binary" as an element of the grammar anywhere. There are 16 grammar rules for "expression". The one that comes closest is
    "expression binop expression", where binop is one of C's 19 binary
    operators, divided into 12 different priority levels.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c on Thu Dec 19 01:35:38 2024
    From Newsgroup: comp.lang.c

    On 18.12.2024 22:04, James Kuyper wrote:
    On 12/12/24 06:38, Janis Papanagnou wrote:
    [...]

    My copy of K&R 1st edition has nothing remotely resembling that.

    I think someone here already mentioned that the English version
    looks different compared to the translation I've in my bookshelf.
    (So I am not sure what your post is actually intending.[*])

    (But that's anyway unimportant to the point I made; that you can
    define semantical information like the precedence separately or
    by syntax.[**])

    Janis

    PS: FYI; Some of your posts, James, arrive also in my mailbox.

    [*] I've put (if you're interested) a scan of that page uploaded
    here: http://volatile.gridbug.de/KR_syntax-rotated90.pdf
    (But similar syntaxes for expressions can be found also in other
    programming languages' contexts; see below.)

    [**] There's various levels of abstraction possible. For example
    - describe expressions in- or semi-formally (e.g. in Bolsky/Korn)
    - describe them without precedence semantics ("K&R DE version")
    - reflect operator precedence in syntax (quite typical)
    - allow extensions/change of operators and precedence (Algol 68)
    (Sometimes there's no clear line; e.g. part of the definitions
    for expressions in Bolsky/Korn are like in the "K&R DE version",
    and the precedence is defined by the order they are listed.)

    [...]

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From James Kuyper@jameskuyper@alumni.caltech.edu to comp.lang.c on Thu Dec 19 06:39:44 2024
    From Newsgroup: comp.lang.c

    On 12/18/24 19:35, Janis Papanagnou wrote:
    On 18.12.2024 22:04, James Kuyper wrote:
    On 12/12/24 06:38, Janis Papanagnou wrote:
    [...]

    My copy of K&R 1st edition has nothing remotely resembling that.

    I think someone here already mentioned that the English version
    looks different compared to the translation I've in my bookshelf.
    (So I am not sure what your post is actually intending.[*])> (But that's anyway unimportant to the point I made; that you can
    define semantical information like the precedence separately or
    by syntax.[**])

    Janis

    PS: FYI; Some of your posts, James, arrive also in my mailbox.

    Yes, as I've explained before, in April, 2021, Thunderbird changed from
    having a Reply button that sends the response to the newsgroup, to
    having a Followup button that does the same thing, and a Reply button
    that sends the response by e-mail to the author. I spent a couple of
    decades learning to hit the Reply button, and at 66 years of age, after
    three years, I'm still finding it difficult to unlearn that habit,
    though I've made some progress.
    [*] I've put (if you're interested) a scan of that page uploaded
    here: http://volatile.gridbug.de/KR_syntax-rotated90.pdf
    (But similar syntaxes for expressions can be found also in other
    programming languages' contexts; see below.)


    It's not just that it "looks different". It is substantially different
    from the First Edition, which had "expression binop expression" as one
    of the rules for expression, with a precedence table for binop. It is
    also substantially different from the second edition, which closely
    matched C89, with a separate grammar production for each level of
    precedence. Nor does it look like a plausible intermediate step between
    those formulations, which is roughly how you described it.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From antispam@antispam@fricas.org (Waldek Hebisch) to comp.lang.c on Thu Dec 19 14:58:24 2024
    From Newsgroup: comp.lang.c

    James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
    On 12/12/24 06:38, Janis Papanagnou wrote:
    On 12.12.2024 06:35, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    [...]
    For (yet another) example; my K&R shows a syntax for expressions like

    expression := binary
    binary := binary + binary
    binary := binary * binary

    That's odd. Is that an exact quotation?

    No, not exact, I abbreviated it; omitted about 25 other operators and
    used another syntax (no ' | '). (Trust me that it hasn't things that
    I called 'factor' and 'term' in my post, which is equivalent to what
    you have formulated below in your copy.) - I'm using a translation of
    something that someone classified as being a "pre-second" edition but
    not quite the first edition. Two references point to 1977 (Prentice
    Hall) and 1978 (Bell Labs). - The text for the "binary" syntax has two
    optional informal columns, the first one has the comment "precedence"
    for some of the variants of "binary" operators. (But it's also just
    titled as "Syntax in Short"; probably presented in a form to make it
    easy to understand without overloading it for purpose of a textbook.)
    It serves the purpose to explain an ambiguous syntax with non-codified
    precedence and a separate precedence table (but it's not an exact "C"
    syntax description as you'd probably find it in standards documents).

    My copy of K&R 1st edition has nothing remotely resembling that. I
    cannot find "binary" as an element of the grammar anywhere. There are 16 grammar rules for "expression". The one that comes closest is
    "expression binop expression", where binop is one of C's 19 binary
    operators, divided into 12 different priority levels.

    Apparently translators took freedom to make various changes.
    Polish translation of 1st edition has rules with translated
    names for nontermials. There are 17 rules for expressions,
    one of which contains binary operator. Text following this
    listens 18 binary operators, divided into 10 priority levels.
    Translators claimed that they removed inaccuracies, but
    probably planted extra confusion by having extra rule for
    comma operator and relating priority of assignment operators
    and other operators.

    BTW: Polish translators also changed examples for K&R style
    to Allman style...
    --
    Waldek Hebisch
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Tim Rentsch@tr.17687@z991.linuxsc.com to comp.lang.c on Mon Dec 23 16:02:26 2024
    From Newsgroup: comp.lang.c

    Michael S <already5chosen@yahoo.com> writes:

    On Wed, 11 Dec 2024 21:19:54 +0000
    bart <bc@freeuk.com> wrote:

    This also comes up with 'while (cond); {...}'.

    $ cat foo.c
    void foo(int x)
    {
    while (x--);
    bar();
    }

    $ clang-format < foo.c
    void foo(int x) {
    while (x--)
    ;
    bar();
    }

    Do I use clamg-format myself? No, I don't.

    And I don't know why C formatters are generally less popular among C programmers then, for example, go formater among Go programmers or Rust formatter among Rust programmers.

    I don't have any experience with Go formatters or Rust formatters.
    My experience with C formatters is that they format too much; in
    some ways they help, but in other ways they interfere with choices
    that are incidental to the high-level adjustments desired. It
    would be nice to see a code formatter that respects low-level
    choices while adjusting high-level format rules. To say this
    another way, the formatting that is done is too rigid - the tool
    always adjusts everything, instead of adjusting only those aspects
    that are needed to fix the high-level transgressions.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Tim Rentsch@tr.17687@z991.linuxsc.com to comp.lang.c on Sat Jan 18 18:48:41 2025
    From Newsgroup: comp.lang.c

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

    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:

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

    If someone wanted to ensure that all static functions defined in a
    translation unit are declared near the top, there could be a separate
    tool to generate, or at least check, the declarations. I'm not aware of >>> any such tool, which suggests there probably isn't much demand for it.

    What it suggests to me is that there are tools being used that
    you aren't aware of.

    What that suggests to me is that you feel the need to snipe without
    sharing any actual information.

    I'm not sniping. I'm just making a statement about what the stated
    facts bring to mind, in my mind. You made a similar kind of
    statement. Is there some reason you think you should be entitled
    to do that and I should not be?
    --- Synchronet 3.20c-Linux NewsLink 1.2