Thank all of you for the information. I finally picked up an approach
of using "&form" and "*file*", and here's my code snippet of the
function:
==============================================================
(defmacro debug
"Print debug info."
[& variables]
(let [datetime "2011-12-17 01:59:37"
naked-msg (str "Debug: " datetime " in " *file* "@" (:line
(meta &form)))]
(if (empty? variables)
(println naked-msg)
`(let [kvs# (zipmap (map #(str % " =>") '~variables)
(vector ~@variables))]
(println (str ~naked-msg ":") kvs#)))))
==============================================================
Basically it works for me now.....But yes, in my code I don't know how
to avoid blowing up problem if there's any loooooong seq variable
there being debugged - if you have any ideas about fixing this issue,
please let me know.
And about the tricky thing by using exception to capture file name &
line number - even though it's also the first idea came into my mind
but - I didn't tried that way because I think this might not be a good
solution. Comparing with using &form, which solution would you prefer
and why? (I prefer to use &form because I think this is more efficient
(but I don't have a proof.....))
On 12月15日, 下午1时48分, jaime <[email protected]> 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 [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