> From the Repl try: (.printStackTrace *e)

Thanks!

>> 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).
>
> 1:10 user=> (defmacro tracefn
>  "Creates trace logging of calls to a function."
>  [function-name]
>  `(def ~function-name
>     (let [old-function# ~function-name]
>       (fn [& args#]
>         (println args#)
>         (print "  ")
>         (let [ret-val# (apply old-function# args#)]
>           (println ret-val#)
>           ret-val#)))))
> nil
> 1:21 user=> (defn foo [x] (inc x))
> #'user/foo
> 1:22 user=> (macroexpand-1 '(tracefn foo))
> (def foo (clojure.core/let [old-function__28__auto__ foo] (clojure.core/fn
> [& args__29__auto__] (clojure.core/println args__29__auto__)
> (clojure.core/print "  ") (clojure.core/let [ret-val__30__auto__
> (clojure.core/apply old-function__28__auto__ args__29__auto__)]
> (clojure.core/println ret-val__30__auto__) ret-val__30__auto__))))

Ok, so I guess it was the eval that was tripping it up.  Do function
"objects" not resolve to themselves in clojure?  I think I'll try
printing the stacktrace and looking at why the code was breaking on
the eval'd value.


>> 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?
>
> 1:6 user=> (println "foo")
> foo
> nil
> 1:7 user=> (prn "foo")
> "foo"
> nil
> 1:8 user=> (println \space)
>
> nil
> 1:9 user=> (prn \space)
> \space
> nil
>
> I would prefer prn.

Point taken :).

Thank you!

--Eric Tschetter

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

Reply via email to