On Fri, Jun 1, 2012 at 8:18 PM, Abraham Egnor <abe.eg...@gmail.com> wrote:
> Is there some technique I'm not seeing to make this kind of simple
> typo-based error less of a hassle to track down?  Or is this simply a matter
> of getting better at deciphering the stack traces?

I think one important point here is that you use two different data
structures to hold the same kind of data. Why use a map of #{:dx :dy
:dz} and a map of #{:x :y :z} for the same use? Why not represent
deltas using :x :y and :z too?
And if we're on this track, why a map? Will the points contain other
important data? If not, I'd just use a vector of n items, representing
n dimensions. This would simplify the code and make it much easier to
maintain. All functions could operate on generic vectors describing
any point in n-dimensional space :-)

Regarding the debugging statement:

If you're using emacs and Slime, there's a full-blown debugger
integrated in swank-clojure. It features breakpoints, watches, etc.
though I rarely use it.
When I encounter such problems, I usually just throw in one or two
println statements printing the parameters. This way it's easy to
check if wrong values are passed.
Adding some asserts is helpful too: In your case it would be wise to
check at the start of the `add' function if `delta' really has the
keys #{:dx :dy :dz}.

-- 
Moritz Ulrich

-- 
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