Live data from Hacker News

Inverse Parentheses

kellett.im

61–67 of 67 posts

Re: Inverse Parentheses

#61

Working with lisp quickly made me realize how over-rated operator precedence (or even the concept of "operators") is. All such effort and early grade-school hours spent on this arbitrary short-hand instead of treating the operations themselves as functions and embracing the divine order of (more) parens.

Do you really like Lisp?

Disclaimer: I used the /royal/ LISP--as in the 'lisp family'- my introduction, and language of choice, has been Clojure (who's qualification as a Lisp is technically contended by certain fundamentalists), but it is still quite paren-based either-way.

And I do, I bounced off it the first time long ago, and really took to it the second go around, its been my daily driver at home and work for some years now- it brings me great joy.

Re: Inverse Parentheses

#62
I've played with operator precedence parsing earlier this year to produce an infix implementation for TXR Lisp.

Documentation entry point: https://www.nongnu.org/txr/txr-manpage.html#N-BEB6083E

I may have invented something new, which I called "Precedence Demotion". I did some research regarding prior art for this exact thing but didn't find it.

https://www.nongnu.org/txr/txr-manpage.html#N-89023B87

LOL, I see I have a bug in the quadratic-roots example (not related to the above). The example has correct results for the given inputs because a is 1.

It's ironic: you add infix to Lisp and, wham, you make a bugeroo because of infix that would never happen in prefix, right in the documentation. Like a poetic justice punishment.

Re: Inverse Parentheses

#63
post #21

Slightly unrelated: Instead of ordinary brackets, one can also use the dot notation. I think it was used in Principia Mathematica or slightly later: (A (B (C D))) would be A . B : C .: D Essentially, the more dots you add, the stronger the grouping operator is binding. The precedence increases with the number of dots. However, this is only a replacement for ordinary parentheses, not for these "reverse" ones discussed…

I believe Peano dot notation works the other way ’round; A . B : C :. D would be, as I understand it, equivalent to: ((A B) C) D The “general principle” is that a larger number of dots indicates a larger subformula. ¹ What if you need to nest parentheses? Then you use more dots. A double dot (:) is like a single dot, but stronger. For example, we write ((1 + 2) × 3) + 4 as 1 + 2 . × 3 : + 4, and the double dot isolat…

Oh you are right, more dots indicate lower operator precedence (weaker binding), not the other way round. Though the explanations you cited seem confusing to me. Apparently by non-programmers.

Re: Inverse Parentheses

#64

The real question is, why does Python even have parentheses? If semantic indent is superior to braces, it ought to beat parentheses, too. The following should yield 14: a = 2 * 3 + 4

Also, don't forget that python has;

  list = [
    1,2,3,
    [ 4, 5 ],
    6
  ]
Without this Python would basically have to be Yaml-ish Lisp:

  =
    a
    *
      2
      +
        3
        4
Let's drop the leading Yaml dashes needed to make ordered list elements. So we have an = node (assignment) which takes an a destination, and a * expression as the source operand. *'s operands are 2 and a + node, whose operands are 3 and 4.

Re: Inverse Parentheses

#67

Earlier quoted context omitted.

Same. That said if you try to use that with ordinary parentheses usage it would get ambiguous as soon as you nest them

Wait, no. It makes no sense to use the same characters! An "inverted" opening parens is visually identical to a "normal" closing parens. IMHO the entire proposition is inane.

Exactly.
Post reply on HN