News for hackers. Stuff that matters.
Re:Partial Operator Precedence by bennettnate5 on Thursday November 05, 2026 @05:22AM (#50377458)
I don't think character length of an expression is the issue. Reading chained operators is explicitly easier than reading nested functions by virtue of operators having infix notation and not explicitly requiring parantheses where they are not necessary to disambiguate order of operations. The prefix notation of functions moves the operation farther from the eye from operands and introduces the issue of parantheses-miscounting bugs. I'd hardly say the difference in readability of these is a non issue:

(a + b + c + d) * e

mult(add(a, add(b, add(c, d))), e)

Re:Partial Operator Precedence by epolanski on Thursday November 05, 2026 @05:23AM (#50377464)
Hence I said that operators are more readable for longer formulas.
Re:Partial Operator Precedence by Zambyte on Thursday November 05, 2026 @05:26AM (#50377478)
mult(add(a, b, c, d), e)

:)

Re:Partial Operator Precedence by mtklein on Thursday November 05, 2026 @06:55AM (#50378087)
At that point,

    (* (+ a b c d) e)
Re:Partial Operator Precedence by Mawr on Thursday November 05, 2026 @05:41AM (#50377589)
> (a + b + c + d) * e

   a
   |> add(b)
   |> add(c)
   |> add(d)
   |> mult(e)
> mult(add(a, add(b, add(c, d))), e)

    c
    |> add(d)
    |> add(b, _)
    |> add(a, _)
    |> mult(e)
Re:Partial Operator Precedence by bennettnate5 on Thursday November 05, 2026 @08:38AM (#50378915)
What a lovely pipe operator you have there to chain the functions and contribute to code readability :)
Re:Partial Operator Precedence by xg15 on Thursday November 05, 2026 @08:36PM (#50387060)
There is also some irony that the function style makes the order of the different addition operations explicit - which in this case is not helpful, because the addition operation is associative. So the parentheses here are just noise.

(Well, almost. You might have weird floating point issues or other bugs, where the associativity does not apply anymore and knowing the evaluation order would be useful. But I think this would be rare situations)