Re:Clojure Cookbook is now accepting contributions
by lukev on Wednesday June 12, 2013 @04:12PM
(#5870408)
The best advice I can give there is, learn how to read a stacktrace. I won't lie, they're messy, but they do contain the information you need to figure out that sort of problem.
For example, all Clojure function calls have the same sort of appearance in the stacktrace, which you'll learn to recognize. You'll be able to pick out "doSomething2" in the trace, which will then help you narrow in on the problem. Recurse through the stack trace using this technique until you find the specific form which is the problem.
Just added a "reading stacktraces" idea to the book: https://github.com/clojure-cookbook/clojure-cookbook/issues/...
Re:Clojure Cookbook is now accepting contributions
by calibraxis on Wednesday June 12, 2013 @03:52PM
(#5870300)
Yeah, I tend to put a `pprint` at various points in the pipeline. (One which returns the form unchanged.)
I use print statements with virtually any programming language, basically using binary search to locate where my assumptions are violated.
Your last paragraph is good advice, but IMO I code like that in general. Consider this code:
(-> x doSomething1 doSomething2 doSomething3)
This was tested as I went, but after the fact, I had to change x. Now any part of the whole series of steps could be broken. This is where I spend 15 minutes trying to understand what the error message means. shrug Maybe this is just what's expected when you're new to clojure.