Hello,
On Fri, Jan 22, 2010 at 3:14 AM, ajay gopalakrishnan <[email protected]>wrote:
> Hi,
>
> I usually debug by adding println statements. How can I achieve the same
> effect in Clojure. I don't think I can introduce println at arbitrary places
> to figure out at which step is the algorithm failing.
>
I also use 'do's as others have suggested. Another trick is to add dummy
variables in lets just to be able to print something. For instance,
(let [a 1
b 2
dummy1 (println "stuff")
c 3]
...)
(this could be done by putting the 2 for b in a do and adding the println in
the do, but that would be more invasive - with the dummy variable, it's just
add/uncomment or delete/comment out one line).
There's also the alternative of adding debug repls, which IMO is in the
spirit of adding printlns, just better if you want interactivity.
http://groups.google.com/group/clojure/browse_thread/thread/8d77ad0da8d190c8/baf2a0bdf87b7dd6?lnk=gst&q=repl+macro#baf2a0bdf87b7dd6
(sorry for the long URL)
also
http://georgejahad.com/clojure/debug-repl-macros.html
for macros.
>
> Thanks,
> Ajay
> --
>
Miron Brezuleanu
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en