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?

On Fri, Jan 22, 2010 at 5:04 PM, ataggart <alex.tagg...@gmail.com> wrote:

>
>
> On Jan 22, 4:13 pm, Mike Meyer <mwm-keyword-googlegroups.
> 620...@mired.org> wrote:
> > 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
>
> I haven't used c.c.trace since it can't be left in place without a
> performance hit.  It seems like it might be useful at the repl, but I
> haven't figured out how to make it do anything interesting, e.g.:
>
> user=> (defn foo [coll] (reduce + coll))
> #'user/bar
> user=> (defn bar [coll] (map inc coll))
> #'user/foo
> user=> (trace (foo (bar [1 1 1])))
> TRACE: 6
> 6
>
> Given that trace is a function and not a macro, this result isn't
> surprising.  I'm sure there *is* a way to actually trace such a call,
> but I haven't figured it out.  It occurs to me that such functionality
> might be worth dropping into c.c.logging, something akin to the spy
> macro.  At least then we could leave the code in place.
>
> --
> 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<clojure%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

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