Reputation: 5977
As i see, clojure has more characters for variable name than c/c++/java. For example:
Functions end with '?' usually return a Boolean, they are predicate.
There are also variables starting with '-', or ending with '!'.
i think these are all clojure-style naming. So, what's the usual naming rule in clojure? is there something in common for clojure programmers?
Upvotes: 15
Views: 3559
Reputation: 1593
Apart from the Library Coding Standards mentioned by @mikera, there is now a (community-driven) Clojure style guide: https://github.com/bbatsov/clojure-style-guide
Upvotes: 0
Reputation: 106351
It's worth looking at Clojure's Library Coding Standards which I think are still probably the best reference on Clojure coding style.
The main function naming conventions seem to be:
frobnicate
frobnicate-with-extra-fizz
my.special.collection/concat
?
to indicate a predicate that returns true or false: sequential?
!
to indicate a function with side effects that is not transaction safe, e.g.: set!
For local variables the following are common:
f
, g
, h
- functionsn
- integer representing a size or countindex
, i
- integer indexx
, y
- numberss
- string inputcoll
- a collectionpred
- a predicate closure& more
- variadic inputUpvotes: 25
Reputation: 24630
Clojure is a dialect of Lisp, so Lisp convention may apply: http://www.cliki.net/naming%20conventions
Upvotes: 2