What are Clojure's Naming Conventions?

tmore picture tmore · Jul 15, 2011 · Viewed 16.4k times · Source

Can anyone explain or point me to where I can find clojure's naming conventions for:

  1. File names
  2. Functions (From what I understand, function names are simply dash separated values)
  3. Variables

Answer

mikera picture mikera · Jul 15, 2011

You might want to look at the Clojure library coding standards on the developer Wiki - this is probably the most comprehensive list that I've seen.

To your specific points:

  1. File names are lowercase, and stored in a directory structure to match the namespace, and end in .clj e.g. "my/special/namespace.clj
  2. Functions are dash-separated-lowercase-words, ideally descriptively chosen so that your code is clear and self-documenting. Don't be afraid to re-use good function names in different namespaces (that is what namespaces are for!).
  3. Variables (by which I assume you mean parameters, let-bound variables etc.) are also usually dash-separated-lowercase-words. Since code-is-data, I think it is appropriate that functions and data have the same naming convention :-)