logoalt Hacker News

bennettnate5 • today at 10:22 AM • 3 replies • view on HN

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)


Replies

Mawr • today at 10:41 AM

> (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)
➕ show 1 reply
Zambyte • today at 10:26 AM

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

:)

➕ show 1 reply
epolanski • today at 10:23 AM

Hence I said that operators are more readable for longer formulas.