Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover debugging of Clojure code... #27

Open
robermann opened this issue Oct 18, 2012 · 8 comments
Open

Cover debugging of Clojure code... #27

robermann opened this issue Oct 18, 2012 · 8 comments

Comments

@robermann
Copy link

...depending on the used IDE / tool.

@freeeve
Copy link
Contributor

freeeve commented Oct 18, 2012

With a section about how to interpret Clojure stack traces. ;)

@robermann
Copy link
Author

Yes you are correct :) Also a list of common errors, with a brief explanation of the most probable causes, would help.

@michaelklishin
Copy link
Member

There are a few exceptions mentioned in the interop guide. There will be more but within reason.

@robermann
Copy link
Author

A debug section should consider:

  • A) Strict debugging tools, as (swank.core/break) or integrated IDE 's debuggers (perhaps the Eclipse's CCW plugin).
  • B) Debugging and inspecting techniques in a broader sense, that could help in understanding how a chunk of code works. I provide my preferred examples of what I'm meaning:
    • B.1) Let's consider a function:
(func1 
 (func2 123) 
 (func3))

If I want to inspect what func2 and func3 return values look like, I can rewrite the whole form using let and do without change the final returned value and in the while checking the intermediate ones:

(let [p1 (func2 123)
      p2 (func3)]
          (do
              (println p1)
              (println p2)
              (func1 p1 p2)))
  • B.2) If I want to temporarily force an evaluated value I can comment the original form and replace it with a value of the same expected type:
(func1 
 #_(func2 123)  ; #_ comments the whole form
  1000          ; forced value, which replaces the commented form
 (func3))

In my opinion these sort of hints could help newbies in their coding activities.

@ifesdjeen
Copy link
Contributor

What helped us a lot in debugging is:

  • nrepl on long-running processes and web applications (a lot!)
  • swapping / wrapping functions during runtime
  • heap dumps / thread dumps / object observing in VisualVm

If there's any interest, I could help out with these.

@ghost
Copy link

ghost commented Jan 30, 2013

could this be done for emacs? I might consider using it(emacs)

@xcthulhu
Copy link

xcthulhu commented Apr 8, 2014

Things that have helped me:

@seancorfield
Copy link
Contributor

I'm am resurrecting this site at https://clojure-doc.github.io so feel free to recreate this issue at https://github.com/clojure-doc/clojure-doc.github.io/issues or submit a PR https://github.com/clojure-doc/clojure-doc.github.io/pulls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants