I'm just starting to teach myself Clojure. As part of supplementing my studies I've watched a few UC Berkley lectures by Brian Harvey on the topic of functional programming. In his second lecture on functional programming, at about minute 34, he uses the applic function to show the order of evaluation. Does Clojure have a feature similar to this? It sure would be handy to see the order of evaluation as I work to understand the whys and wherefores.
You can do just in REPL (answer by Mike Meyer in Clojure mailing list: Debugging in Clojure)
=> (use 'clojure.contrib.trace)
nil
=> (defn foo [coll] (reduce + coll))
#'web-db.core/foo
=> (defn bar [coll] (map inc coll))
#'web-db.core/bar
=> (dotrace [foo bar] (foo (bar [1 1 1])))
TRACE t3868: (bar [1 1 1])
TRACE t3868: => (2 2 2)
TRACE t3869: (foo (2 2 2))
TRACE t3869: => 6
6
there are also Clojure Debugging Toolkit ("Ridiculously long instructions on how to use it are here: http://georgejahad.com/clojure/emacs-cdt.html ")
And some IDE (like Eclipse with Counterclockwise plugin) allow to debug: to set breakpoints, see locals, step in/out, ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With