When I want to add print commands for debugging, I usually either do it the
way David Nolen described, i.e., binding _ to a printf statement, or I use
a little utility macro like this (picked up from stackoverflow):

(defmacro dbg[x] `(let [x# ~x] (println "dbg:" '~x "=" x#) x#))


I agree with Evan Gamble that I frequently end up with code that is a
mixture of conditional branching and binding.  This results in highly
indented and less readable code and I think Clojure would really benefit
from some additions to ameliorate this.

Evan's solution (https://github.com/egamble/let-else) allows you to put
conditions in your let.
Cgrand's solution (https://github.com/cgrand/utils) allows you to put lets
in your cond.

Either way works well.  I think Evan's way results in somewhat more compact
code for the common case, whereas Cgrand's way feels a little more
versatile (and his "flatter cond" is what I use).  I strongly urge you to
pick one of these two techniques and include it in your project.  Once you
try it and see how much cleaner the code is, you'll be hooked.

--Mark

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to