clojure-style-guide
clojure-style-guide copied to clipboard
Thread on single line with single-argument functions
When threading a few calls single-argument calls that will fit within 80 characters, prefer a single line.
;; good
(-> x fizz :foo first frob)
;; not as good
(-> x
fizz
:foo
first
frob)
But when one of more functions takes arguments, split each call onto a separate line.
;; good
(-> x
(fizz a b)
:foo
first
(frob x y))
;; not as good
(-> x (fizz a b) :foo first (frob x y))
I agree with the general premise, although I guess that's a bit subjective. Still, I wouldn't mind if we mention those suggestions in the guide.
This seems subjective to me and hard to make a recommendation for when to use one or the other.
Often I find that I'll split a threading macro onto multiple lines if I want to really emphasis what is happening. Other times I'll leave it on a single line if it's a trivial transformation, even if there is a functional call with arguments.
Same here.