(odd? a) 1
:let [a (quot a 2)]
:when-let [x (fn-which-may-return-nil a),
y (fn-which-may-return-nil (* 2 a))]
:when (seq x)
:do (println x)
(odd? (+ x y)) 2
The :do performs a side-effecting statement if it gets that far in the cond. :do is my favorite bonus addition for cond beyond :let. I find I use it a lot to quickly insert some debugging print commands without needing to change the shape of my code, so it can be trivially removed later.
When :do did not exist, but :let did exist in my cond macro, I found myself frequently writing things like:
:let [_ (println x)]
in order to insert a side-effecting statement into the cond sequence.
:do is a cleaner solution.
:when only continues with the cond if the value is truthy, otherwise it bails out of the cond with nil.
:when-some (not yet merged in) will do much the same thing, but continuing if non-nil, rather than truthy.
:when, :when-some, and :when-let don't add a whole lot of richness. For example, that :when line in the example could just have easily been written as:
(not (seq x)) nil
But using these can potentially add clarity of intention, so even though I could make do without them, I go ahead and use them when relevant.
In better-cond's cond macro, that final :else is optional. You may prefer the new cond-let library if you want to continue enforcing the use of :else on the last clause.
To reiterate, :let is by far the most valuable addition, and I find :do to be the second-most valuable addition. Other additions are fairly minor syntactic sugar.