Skip to content

Clojure style guide

Christopher Small edited this page May 17, 2014 · 5 revisions

It would be nice if we could agree on some things regarding coding style for Clojure.

Code style

  • If m is a hash map, use (:key m) instead of (m :key) wherever possible. The former will still work if m is re-implemented as a record, but not the latter.
  • Prefer maps over records unless they become preferable for some reason down the road (for performance for instance). Note that while still simple they don't have the same level of structural sharing, so unless you need the performance better to avoid. We may modify this policy if we decide the expressiveness and self-documentation around a particular structure would benefit from being a record, but let's in general err on the side of simplicity for now.

Formatting style

Silly stuff, but it makes things easier to look at...

  • 2 spaces indentation

More to follow...

Clone this wiki locally