On Fri, 22 Jan 2010 10:08:45 +0200
Miron Brezuleanu <mbr...@gmail.com> wrote:

> Hello,
> 
> On Fri, Jan 22, 2010 at 3:14 AM, ajay gopalakrishnan 
> <ajgop...@gmail.com>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).
> 

Um, I'm surprised that no one has mentioned clojure.contrib.trace.
Given that Clojure is mostly functional, those "debugging" printlns
will mostly be arguments to functions, or values coming out of
them. The trace package lets you evaluate an expression at the repl,
tracing the values in and out of a user-specified set of functions
during the evaluation process.

That's what I'd consider the idiomatic way to do debugging in a LISP.

          <mike
-- 
Mike Meyer <m...@mired.org>             http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

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