• Superparens ... awesome?

    From luserdroog@21:1/5 to All on Thu Nov 25 17:39:09 2021
    Digging back into the source code of my olmec language, I rediscovered
    that it allows "superparens". That is, it can infer any missing parentheses
    on the outside edges of expressions. So you only need to add whatever
    inner parens might be needed to disambiguate. eg.

    2*3)+4

    It's conceivable that right parens might become pretty scare, since all precedence the same and all associativity is right-to-left (like APL).

    Awesome?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dmitry A. Kazakov@21:1/5 to luserdroog on Fri Nov 26 08:33:05 2021
    On 2021-11-26 02:39, luserdroog wrote:
    Digging back into the source code of my olmec language, I rediscovered
    that it allows "superparens". That is, it can infer any missing parentheses on the outside edges of expressions. So you only need to add whatever
    inner parens might be needed to disambiguate. eg.

    2*3)+4

    The parser I use can add missing parenthesis and also infer infix
    operators, e.g.

    A B + C ---> A * B + C

    It's conceivable that right parens might become pretty scare, since all precedence the same and all associativity is right-to-left (like APL).

    Awesome?

    No, because the place of the missing parenthesis cannot be inferred:

    A + B + C)

    A + (B + C + D))

    etc.

    --
    Regards,
    Dmitry A. Kazakov
    http://www.dmitry-kazakov.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Harris@21:1/5 to luserdroog on Fri Nov 26 17:34:32 2021
    On 26/11/2021 01:39, luserdroog wrote:
    Digging back into the source code of my olmec language, I rediscovered
    that it allows "superparens". That is, it can infer any missing parentheses on the outside edges of expressions. So you only need to add whatever
    inner parens might be needed to disambiguate. eg.

    2*3)+4

    It's conceivable that right parens might become pretty scare, since all precedence the same and all associativity is right-to-left (like APL).

    Awesome?

    Not awesome!

    One advantage of syntax and semantic checks is to prompt a programmer to
    make code unambiguous. If a compiler started to guess at how a piece of
    code should be corrected then it might make different guesses from what
    a programmer would expect.


    --
    James Harris

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From luserdroog@21:1/5 to Dmitry A. Kazakov on Fri Nov 26 18:19:28 2021
    On Friday, November 26, 2021 at 1:33:12 AM UTC-6, Dmitry A. Kazakov wrote:
    On 2021-11-26 02:39, luserdroog wrote:
    Digging back into the source code of my olmec language, I rediscovered
    that it allows "superparens". That is, it can infer any missing parentheses on the outside edges of expressions. So you only need to add whatever
    inner parens might be needed to disambiguate. eg.

    2*3)+4
    The parser I use can add missing parenthesis and also infer infix
    operators, e.g.

    A B + C ---> A * B + C
    It's conceivable that right parens might become pretty scare, since all precedence the same and all associativity is right-to-left (like APL).

    Awesome?
    No, because the place of the missing parenthesis cannot be inferred:

    A + B + C)

    A + (B + C + D))

    etc.


    Well, it may not actually be useful. But by my definitions, it isn't ambiguous. Parens are only inferred at the edges. So for your two examples, it wouldn't change anything really: an extra open paren '(' would be added to the left edge.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From luserdroog@21:1/5 to James Harris on Fri Nov 26 18:21:41 2021
    On Friday, November 26, 2021 at 11:34:33 AM UTC-6, James Harris wrote:
    On 26/11/2021 01:39, luserdroog wrote:
    Digging back into the source code of my olmec language, I rediscovered
    that it allows "superparens". That is, it can infer any missing parentheses on the outside edges of expressions. So you only need to add whatever
    inner parens might be needed to disambiguate. eg.

    2*3)+4

    It's conceivable that right parens might become pretty scare, since all precedence the same and all associativity is right-to-left (like APL).

    Awesome?
    Not awesome!

    One advantage of syntax and semantic checks is to prompt a programmer to
    make code unambiguous. If a compiler started to guess at how a piece of
    code should be corrected then it might make different guesses from what
    a programmer would expect.



    That's true and all. But with the superparens, they're only added in cases where there's no ambiguity. If it were Lisp, it would save you from counting and closing all your stuff at the end. You just stop. Hit enter. done.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Pemberton@21:1/5 to James Harris on Sat Nov 27 04:37:14 2021
    On Fri, 26 Nov 2021 17:34:32 +0000
    James Harris <james.harris.1@gmail.com> wrote:

    On 26/11/2021 01:39, luserdroog wrote:

    Digging back into the source code of my olmec language, I
    rediscovered that it allows "superparens". That is, it can infer
    any missing parentheses on the outside edges of expressions. So you
    only need to add whatever inner parens might be needed to
    disambiguate. eg.

    2*3)+4

    It's conceivable that right parens might become pretty scare, since
    all precedence the same and all associativity is right-to-left
    (like APL).

    Awesome?

    Not awesome!

    One advantage of syntax and semantic checks is to prompt a programmer
    to make code unambiguous. If a compiler started to guess at how a
    piece of code should be corrected then it might make different
    guesses from what a programmer would expect.


    I believe your response was serious and genuine, but I can't help think
    you were messing with this guy just a bit, especially given how the C
    language handles this issue. C programmers routinely add parenthesis
    to make sure the C compiler parses expressions the way the programmer
    intended, and not the way C's precedence rules dictate. I.e., from the programmer's perspective, the C compiler is "guessing", due to the
    precedence rules, "at how a piece of code should be [understood]".


    --
    "If Britain were to join the United States, it would be the
    second-poorest state, behind Alabama and ahead of Mississippi,"
    Hunter Schwarz, Washington Post

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dmitry A. Kazakov@21:1/5 to luserdroog on Sat Nov 27 10:54:51 2021
    On 2021-11-27 03:19, luserdroog wrote:
    On Friday, November 26, 2021 at 1:33:12 AM UTC-6, Dmitry A. Kazakov wrote:
    On 2021-11-26 02:39, luserdroog wrote:
    Digging back into the source code of my olmec language, I rediscovered
    that it allows "superparens". That is, it can infer any missing parentheses >>> on the outside edges of expressions. So you only need to add whatever
    inner parens might be needed to disambiguate. eg.

    2*3)+4
    The parser I use can add missing parenthesis and also infer infix
    operators, e.g.

    A B + C ---> A * B + C
    It's conceivable that right parens might become pretty scare, since all
    precedence the same and all associativity is right-to-left (like APL).

    Awesome?
    No, because the place of the missing parenthesis cannot be inferred:

    A + B + C)

    A + (B + C + D))

    etc.


    Well, it may not actually be useful. But by my definitions, it isn't ambiguous.
    Parens are only inferred at the edges. So for your two examples, it wouldn't change anything really: an extra open paren '(' would be added to the left edge.

    No, the rightmost "stub" which in presence of mixed parenthesis and
    commas it could be different, e.g.

    A + C [ D + F ) ]
    ^
    | stub

    In my parser it could be even further to the right, but that would
    require inspection of the operators stack before rolling it up.

    --
    Regards,
    Dmitry A. Kazakov
    http://www.dmitry-kazakov.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Pemberton@21:1/5 to luserdroog on Sat Nov 27 04:50:18 2021
    On Fri, 26 Nov 2021 18:21:41 -0800 (PST)
    luserdroog <mijoryx@yahoo.com> wrote:

    On Friday, November 26, 2021 at 11:34:33 AM UTC-6, James Harris wrote:
    On 26/11/2021 01:39, luserdroog wrote:

    Digging back into the source code of my olmec language, I
    rediscovered that it allows "superparens". That is, it can infer
    any missing parentheses on the outside edges of expressions. So
    you only need to add whatever inner parens might be needed to disambiguate. eg.

    2*3)+4

    It's conceivable that right parens might become pretty scare,
    since all precedence the same and all associativity is
    right-to-left (like APL).

    Awesome?
    Not awesome!

    One advantage of syntax and semantic checks is to prompt a
    programmer to make code unambiguous. If a compiler started to guess
    at how a piece of code should be corrected then it might make
    different guesses from what a programmer would expect.



    That's true and all. But with the superparens, they're only added in
    cases where there's no ambiguity. If it were Lisp, it would save you
    from counting and closing all your stuff at the end. You just stop.
    Hit enter. done.

    ...

    no ambiguity

    When does that exist? ...

    Do you understand how a C expression is parsed without the parentheses?
    I don't. I've been programming C for three decades. Without the
    parentheses, I have to look up the precedence rules in a table in a
    book, largely because they're not what I would expect and there are too
    many of them to easily remember. In general, C programmers add extra
    parens, because no one knows what those rules are, especially since
    most C programmers don't have the correct book, or any book for that
    matter, nor the C standard available.

    Also, the other guys posting here haven't decided to do things the same
    way even for simple math operators, which are well defined by an
    entirely different field, i.e., mathematics versus computer science.
    So, why would you expect someone else reading your code to come to the
    same conclusion as you as to how to properly interpret the placement of parenthesis or how precedence rules should be applied? E.g., about 2
    billion people read right-to-left. That's alot of people. Do the
    other 5 billion people who read left-to-right get to say that they're
    wrong?


    --
    "If Britain were to join the United States, it would be the
    second-poorest state, behind Alabama and ahead of Mississippi,"
    Hunter Schwarz, Washington Post

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Harris@21:1/5 to Rod Pemberton on Sat Nov 27 10:16:52 2021
    On 27/11/2021 09:37, Rod Pemberton wrote:
    On Fri, 26 Nov 2021 17:34:32 +0000
    James Harris <james.harris.1@gmail.com> wrote:

    On 26/11/2021 01:39, luserdroog wrote:

    Digging back into the source code of my olmec language, I
    rediscovered that it allows "superparens". That is, it can infer
    any missing parentheses on the outside edges of expressions. So you
    only need to add whatever inner parens might be needed to
    disambiguate. eg.

    2*3)+4

    It's conceivable that right parens might become pretty scare, since
    all precedence the same and all associativity is right-to-left
    (like APL).

    Awesome?

    Not awesome!

    One advantage of syntax and semantic checks is to prompt a programmer
    to make code unambiguous. If a compiler started to guess at how a
    piece of code should be corrected then it might make different
    guesses from what a programmer would expect.


    I believe your response was serious and genuine, but I can't help think
    you were messing with this guy just a bit, especially given how the C language handles this issue. C programmers routinely add parenthesis
    to make sure the C compiler parses expressions the way the programmer intended, and not the way C's precedence rules dictate. I.e., from the programmer's perspective, the C compiler is "guessing", due to the
    precedence rules, "at how a piece of code should be [understood]".

    I wasn't messing with him at all and I wasn't thinking about C. It's
    just a general principle that autocorrections may guess wrong.

    If you think C's precedence rules are hard to remember just imagine
    having to remember what autocorrections a compiler might apply. It would
    be a complete nightmare!

    Where autocorrections can be useful is in allowing a compiler to try to
    compile more code and report more errors from a single run but it
    shouldn't produce an object module from code with any errors in it, IMO.


    --
    James Harris

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From luserdroog@21:1/5 to James Harris on Sat Nov 27 05:42:06 2021
    On Saturday, November 27, 2021 at 4:16:55 AM UTC-6, James Harris wrote:
    On 27/11/2021 09:37, Rod Pemberton wrote:
    On Fri, 26 Nov 2021 17:34:32 +0000
    James Harris <james.h...@gmail.com> wrote:

    On 26/11/2021 01:39, luserdroog wrote:

    Digging back into the source code of my olmec language, I
    rediscovered that it allows "superparens". That is, it can infer
    any missing parentheses on the outside edges of expressions. So you
    only need to add whatever inner parens might be needed to
    disambiguate. eg.

    2*3)+4

    It's conceivable that right parens might become pretty scare, since
    all precedence the same and all associativity is right-to-left
    (like APL).

    Awesome?

    Not awesome!

    One advantage of syntax and semantic checks is to prompt a programmer
    to make code unambiguous. If a compiler started to guess at how a
    piece of code should be corrected then it might make different
    guesses from what a programmer would expect.


    I believe your response was serious and genuine, but I can't help think
    you were messing with this guy just a bit, especially given how the C language handles this issue. C programmers routinely add parenthesis
    to make sure the C compiler parses expressions the way the programmer intended, and not the way C's precedence rules dictate. I.e., from the programmer's perspective, the C compiler is "guessing", due to the precedence rules, "at how a piece of code should be [understood]".
    I wasn't messing with him at all and I wasn't thinking about C. It's
    just a general principle that autocorrections may guess wrong.

    If you think C's precedence rules are hard to remember just imagine
    having to remember what autocorrections a compiler might apply. It would
    be a complete nightmare!

    Where autocorrections can be useful is in allowing a compiler to try to compile more code and report more errors from a single run but it
    shouldn't produce an object module from code with any errors in it, IMO.

    I think you're right that precedence and superparens wouldn't work well together. But they don't have to! Olmec is a variant of APL: no precedence.
    Ok, there's a slight bit of precedence between adverbs and verbs
    (or operators and functions, or higher level functions and primitive functions).

    And again, parens are only implicitly added at the outside edges of
    expression. The programmer has to add any important ones that
    govern how the expression executes. You're just allowed to omit
    extra opening or closing parens at the start or end of the expression. Expressions are already delimited by line breaks. There are no provisions
    for "line continuation" or similar.

    I maybe forgot to explain the weird set of goals for this language.
    It's intended to be a compromise between a nice general purpose
    language and a golfing language. And for the golfing side, being able
    to just rip out extra bytes seems like a big win.

    Again again, parens are only inferred at the edges. Hard edges that
    already exist.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bart@21:1/5 to luserdroog on Sat Nov 27 14:06:32 2021
    On 27/11/2021 13:42, luserdroog wrote:
    On Saturday, November 27, 2021 at 4:16:55 AM UTC-6, James Harris wrote:

    Where autocorrections can be useful is in allowing a compiler to try to
    compile more code and report more errors from a single run but it
    shouldn't produce an object module from code with any errors in it, IMO.

    And again, parens are only implicitly added at the outside edges of expression. The programmer has to add any important ones that
    govern how the expression executes. You're just allowed to omit
    extra opening or closing parens at the start or end of the expression. Expressions are already delimited by line breaks. There are no provisions
    for "line continuation" or similar.

    I maybe forgot to explain the weird set of goals for this language.
    It's intended to be a compromise between a nice general purpose
    language and a golfing language. And for the golfing side, being able
    to just rip out extra bytes seems like a big win.

    Is that allowed in code golf, that you can just make up your own
    language to gain an advantage?

    Because what stops someone creating a language with a single,
    1-character keyword that will perform some specific task?

    Or maybe the implementation (on top of some common language or platform)
    is included... (I've never tried it).

    Again again, parens are only inferred at the edges. Hard edges that
    already exist.

    My Casio calculator does that, but only at the right edge. I find it convenient, but in that context, the right edge is also the end of the 'program'. Nothing else follows that might cause ambiguity.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From luserdroog@21:1/5 to Bart on Sat Nov 27 06:45:58 2021
    On Saturday, November 27, 2021 at 8:06:33 AM UTC-6, Bart wrote:
    On 27/11/2021 13:42, luserdroog wrote:
    On Saturday, November 27, 2021 at 4:16:55 AM UTC-6, James Harris wrote:

    Where autocorrections can be useful is in allowing a compiler to try to
    compile more code and report more errors from a single run but it
    shouldn't produce an object module from code with any errors in it, IMO.
    And again, parens are only implicitly added at the outside edges of expression. The programmer has to add any important ones that
    govern how the expression executes. You're just allowed to omit
    extra opening or closing parens at the start or end of the expression. Expressions are already delimited by line breaks. There are no provisions for "line continuation" or similar.

    I maybe forgot to explain the weird set of goals for this language.
    It's intended to be a compromise between a nice general purpose
    language and a golfing language. And for the golfing side, being able
    to just rip out extra bytes seems like a big win.
    Is that allowed in code golf, that you can just make up your own
    language to gain an advantage?

    Because what stops someone creating a language with a single,
    1-character keyword that will perform some specific task?

    Yes, with restrictions. At codegolf.stackexchange.com (last I checked)
    The language has to already exist at the time the challenge is posted.
    So you can learn from previous challenges and improve your language,
    but you can only use those improvements in future challenges (specifying
    the version or release of the language that's required).

    And a lot of special trickery has been specifically ruled out like
    that program hc9++?? something something. It can work like cat or
    cow or several other things. They really want it to be a real language
    rather than just a swiss army knife.

    Or maybe the implementation (on top of some common language or platform)
    is included... (I've never tried it).
    Again again, parens are only inferred at the edges. Hard edges that
    already exist.
    My Casio calculator does that, but only at the right edge. I find it convenient, but in that context, the right edge is also the end of the 'program'. Nothing else follows that might cause ambiguity.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From luserdroog@21:1/5 to luserdroog on Thu Dec 2 19:40:07 2021
    On Thursday, November 25, 2021 at 7:39:10 PM UTC-6, luserdroog wrote:
    Digging back into the source code of my olmec language, I rediscovered
    that it allows "superparens". That is, it can infer any missing parentheses on the outside edges of expressions. So you only need to add whatever
    inner parens might be needed to disambiguate. eg.

    2*3)+4

    It's conceivable that right parens might become pretty scare, since all precedence the same and all associativity is right-to-left (like APL).

    Awesome?

    Did I win? They're awesome, right?

    I do quite like Dmitry's idea of inferring juxtaposition as an operator,
    but I don't think I can use it for Olmec. The APL parentage already
    interprets juxtaposition as (con)catenation. If you do happen to
    end up with 2 distinct array objects juxtaposed in an expression,
    then that could lead to a parsing or execution error. Or maybe one
    or the other will get scooped up by a higher order function and yield
    a function that operates on the other array. So, yeah. Can't use it.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tim Rentsch@21:1/5 to Rod Pemberton on Wed Dec 8 19:25:37 2021
    Rod Pemberton <noemail@basdxcqvbe.com> writes:

    [...]

    Do you understand how a C expression is parsed without the
    parentheses? I don't. I've been programming C for three decades.
    Without the parentheses, I have to look up the precedence rules in a
    table in a book, [...]

    Then shame on you. I have no sympathy.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Rod Pemberton on Thu Dec 9 10:49:02 2021
    On 27/11/2021 10:50, Rod Pemberton wrote:

    Do you understand how a C expression is parsed without the parentheses?
    I don't. I've been programming C for three decades. Without the parentheses, I have to look up the precedence rules in a table in a
    book, largely because they're not what I would expect and there are too
    many of them to easily remember. In general, C programmers add extra
    parens, because no one knows what those rules are, especially since
    most C programmers don't have the correct book, or any book for that
    matter, nor the C standard available.


    Most people have the internet available these days. It is not hard to
    google for C operator precedence rules.

    (It's not hard to find the free draft versions of the C standards
    either, but that does not make them easy to read!)

    A good reference for C is :

    <https://en.cppreference.com/w/c>

    The same site also has C++, and it is recommended and supported by the C
    and C++ groups at ISO. It is a reference, not a tutorial, but worth bookmarking for any C or C++ programmer.

    And a good online compiler is a great resource for learning or testing
    code. <https://godbolt.org> has a wide selection of compilers and
    programming languages - I use it regularly in my work.

    In the particular case of parenthesis and operator precedence, I think
    the common operators are easy to remember, and are reasonably logical.
    It gets harder with the rarer ones - primarily because you don't
    remember things you don't use much.

    I'm a fan of adding extra parenthesis, as long as they serve a purpose -
    I write:

    (x >= 10) && (x < 20)

    To me, the only reason to write that without parenthesis would be to
    brag about how the writer knows all the precedence rules. It is simply
    clearer to group logical parts of an expression, and parentheses help
    there - it's all clearer to the reader.

    Local variables are free. Large expressions can be broken up in
    separate lines with separate parts. This gives you more room, lets you
    use names, lets you be clear about types, gives you place to add
    comments explaining the purpose of the expressions, and makes it all
    easier to maintain and friendlier for source code management, change
    management and code reviews.


    (This applies to all languages, of course, not just C.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)