This will print all the debug information at compile time, which is usually not what you want. I have a little macro I use called ?, which looks like:
(defmacro ? [x] `(let [x# ~x] (prn '~x '~'is x#) x#)) You could add file and line information to this fairly simply: (defmacro ? [x] (let [line (:line (meta &form)) file *file*] `(let [x# ~x] (println (pr-str '~x) "is" (pr-str x#) (str "; (" ~file ":" ~line ")")) x#))) And use it like so: user> (let [x 10] (+ 5 (? x))) x is 10 ; (NO_SOURCE_FILE:1) 15 On Dec 15, 5:19 am, Jay Fields <j...@jayfields.com> wrote: > This should get you started: > > (defmacro debug [x] > (println x) > (println (pr-str &form)) > (println *file*) > (println (meta &form))) > > > > > > > > On Thu, Dec 15, 2011 at 12:48 AM, jaime <xiejianm...@gmail.com> wrote: > > Hello there, > > > I want to write a function named "debug" which will print out "date- > > time msg + current source-line + etc. info", but I don't know how to > > get the current source and line number of the running point (just like > > what REPL does when encounter any exceptions) ... > > > Got any ideas? > > > Thanks! > > > -- > > 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 -- 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