Re:A few tips for writing macros in Clojure
by roboguy12 on Monday May 09, 2016 @10:48PM
(#11664862)
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
is so much easier for me to read to read than
But when working with functions, I much prefer the standard Clojure syntax.
[ Parent
| on HN ]
Re:A few tips for writing macros in Clojure
by malloryerik on Tuesday May 10, 2016 @06:26AM
(#11666154)
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.