> When you look at the backtrace of the exception you will find > (very far down the trace) lines like "caused by..". There you > normally find more useful information than "ExceptionInInitializer".
I don't get a backtrace, all I get is what I put in the original message. How do I turn on full backtraces? >> user=> (defmacro tracefn [function-name] >> "Creates trace logging of calls to a function." >> `(def ~function-name (let [old-function# ~(eval function-name)] > > You don't want eval here. Only ~function-name. If you use eval > somewhere it's almost always wrong. There are uses for eval, > but they are veeery rare. The thing is, I want to store the actual *function* not the symbol referencing the function (the symbol's reference changes after the macro is evaluated). >> (fn [& args#] >> (println args#) >> (print " ") >> (let [ret-val# (apply old-function# args#)] >> (println ret-val#) >> ret-val#))))) > > Maybe you want to use prn instead of println? Is that just to give the user flexibility on whether they want to flush on new line? Or is there some other reason to choose prn over println? >> user=> (defn poor-mans-multiply [x y] >> (if (> x 0) >> (+ y (poor-mans-multiply (dec x) y)) >> 0)) > > Also not related and I suspect this to be just an example, but > nevertheless: the JVM does not support tail call optimisation. > So this function will blow up the stack for sufficiently large > values of x. You might want to look at the trampoline utility > function. Oh yeah, it's just a stupid function that I wrote up to help me verify tracing. > And finally you might find this useful: > http://groups.google.com/group/clojure/browse_frm/thread/3ea8777880231e18/6fd1b352ac1a6744?lnk=gst&q=trace#6fd1b352ac1a6744 I looked at the trace.clj in clojure.contrib and it looks like it will resolve my current wants for trace functionality, but I chose to post this anyway because I wanted to know if clojure can handle "AOP-esque" macros that wrap function and replace its base definition (that's basically what I'm doing). --Eric --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---