bbatsov/clojure-style-guide

namespace line breaks

dijonkitchen opened this issue · 5 comments

Unsure why line breaks haven't always been the case since it helps sorting, readability, diffs, and making sure lines aren't too long.

https://stuartsierra.com/2016/clojure-how-to-ns.html#line-breaks

agzam commented

I'm also curious how this convention got established - it seems all the linters, CIDER (cljr-clean-ns), etc. always prefer to start requires on the same line, while clearly it is better (for a few obvious reasons) to have it on the next line.

From the article: "This recommendation is slightly different from common practice", which is certainly my experience. At most the extra line break should be presented as be a valid option, IMO, since so much code in the wild doesn't have the break (and it has the disadvantage of making the average ns declaration one line longer).

I always use this style:

;; Good
(:require
 [clojure.string :as string]
 [io.pedestal.http :as http])

But admittedly the other one is way more popular (likely for historical reasons). I guess it was used in the early examples of the ns macro and people just went with the flow.

Maybe it was from one-line requires for small namespaces that were just extended instead of having an indented one.

Shall we just update the example here? https://github.com/bbatsov/clojure-style-guide#comprehensive-ns-declaration

Yeah, that's fine by me. Generally speaking, I think there's a lot of good advice from Stuart's article that's worth incorporating here.