Hi Alexandru, As Andy pointed out there's the emacs+Ritz option which has quite a few features, but if the main thing you want to do is inspect the locals and the current stack trace, you could use a macro as the one presented in the book The Joy of Clojure <http://joyofclojure.com/> (Chapter 8: Macros).
The macro that's presented there is called *break*. What it does is it traps the existing locals in a Clojure map when the macro is called and uses their values to *eval* the forms you input in the *break*ing repl. The version in the book uses *clojure.main/repl* with some options to cange the prompt, the reader and the evaler. Here's the full code for the break macro almost the same as in the book, I added the *:locals* "command" that will print the map of locals. (defn readr [locals prompt exit-code] (let [input (clojure.main/repl-read prompt exit-code)] (if (= input :quit) exit-code (do (when (= input :locals) (println locals)) input)))) (defn contextual-eval [ctx expr] (eval `(let [~@(mapcat (fn [[k v]] [k `'~v]) ctx)] ~expr))) (defmacro local-context [] (let [symbols (keys &env)] `(zipmap '~symbols (list ~@symbols)))) (defmacro break [] `(clojure.main/repl :prompt #(print "debug=> ") :read (partial readr (local-context)) :eval (partial contextual-eval (local-context)))) (defn f [x] (let [y 1 z 2] (break))) ; (f 3) ; :locals ; :quit HTH, J On Monday, November 11, 2013 2:33:44 PM UTC+8, Alexandru Nedelcu wrote: > > Hi, > > I'm a rookie. Having worked with Python and Ruby, I love how in those > languages you can simply do something like: > > import pdb; pdb.set_trace() > > Or in Ruby: > > require 'ruby-debug'; debugger > > So is there any way in Clojure to pause execution and open some sort > of debugger / REPL in the console with the current stack-trace and > local vars visible? > > Thanks, > > -- > Alexandru Nedelcu > www.bionicspirit.com > > PGP Public Key: http://goo.gl/ZyQpGv > -- -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.