Hacker News new | ask | show | jobs
by roboguy12 3691 days ago
I thought that at first too about infixes being better (I've only been using Clojure for a few months), but I'm beginning to find the opposite. The only times when I miss an infix syntax is when doing math

    1 + (2 * 10) - (12 / 3)
is so much easier for me to read to read than

    (- (+ 1 (* 2 10) (/ 12 3)))
But when working with functions, I much prefer the standard Clojure syntax.
2 comments

I believe the parens are off by one in the Clojure example and that it should be:

    (- (+ 1 (* 2 10)) (/ 12 3))   ;=> 17
I've found the threading operator can help in these cases.

    (-> (+ 1) (+ (* 2 10) (- (/ 12 3)))) 

Or, line breaks can clarify:

    (- (+ 1 (* 2 10))
       (/ 12 3))
or at the risk of overdoing it:

    (- 
      (+ 1 (* 2 10))
      (/ 12 3))
Now I know at first glance that I'm subtracting the results of those two lines from each other. Indeed the last two might be almost as clear as the infix, and are without any order of operations rules.

Also some don't like colored parens but I find them very clarifying.

I have to disagree.

    f x . g
reads just so much easier than

    (comp (partial f x) g)