On Jan 22, 6:27 pm, Mike Meyer <mwm-keyword-googlegroups.
620...@mired.org> wrote:
> On Fri, 22 Jan 2010 17:25:39 -0800
>
> ajay gopalakrishnan <ajgop...@gmail.com> wrote:
> > I dont mind using println. The problem is that needs to be inside a do or
> > when ... and that is not really part of my code. When the time comes to
> > remove the prints, i need to remove all these do blocks too. I can leave
> > them as it is I guess, but then it is not neat and non-idiomatic. From all
> > the replies, it seems that Debugging is going to be a pain in the Lisp style
> > languages. How do people in Lisp/Scheme debug it?
>
> In the REPL. That's a pretty complete debugger, all by itself. In
> something like SLIME, you get the ability to examine the call stack,
> etc. while things are running.
>
> The trace package just dumps arguments/results of functions while they
> run. It's a primitive tool, but better than println's in many cases:
>
> user it, then use dotrace:
>
> user> (use 'clojure.contrib.trace)
> nil
> user> (defn foo [coll] (reduce + coll))
> #'user/foo
> user> (defn bar [coll] (map inc coll))
> #'user/bar
> user> (dotrace [foo bar] (foo (bar [1 1 1])))
> TRACE t7043: (bar [1 1 1])
> TRACE t7043: => (2 2 2)
> TRACE t7044: (foo (2 2 2))
> TRACE t7044: => 6
> 6
> user> (dotrace [foo +] (foo (bar [1 1 1])))
> TRACE t7071: (foo (2 2 2))
> TRACE t7072: |    (+ 2 2)
> TRACE t7072: |    => 4
> TRACE t7073: |    (+ 4 2)
> TRACE t7073: |    => 6
> TRACE t7071: => 6
> 6
>
> and so on.
>
>     <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

See, I *knew* there had to be a way to do it!  Clearly I wasn't
grokking the docs for dotrace.  If the authors of of c.c.trace are
amenable, I'm inclined to add this functionality to a variant of the
c.c.logging/spy macro, something like:

(spy [foo bar] (foo (bar [1 1 1])))

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