On 3 Mai, 15:58, Mark Volkmann <r.mark.volkm...@gmail.com> wrote:
> Is there a special variable that holds the name of the currently
> running function so it can be output in a logging message?
>
> I'm thinking of something like this:
>
> (defn my-function []
>   (println "entered" *current-function*)
>   ...
> )

One way to solve this could be to write an anaphoric macro
over defn.  Example:
(defmacro defnamed [name params & body]
  `(let [~'*fn-name* ~(str name)]
     (defn ~name ~params
       ~...@body)))

Then you can
(defnamed foo [a b]
  (println (+ a b) *fn-name*))

When the compiler is clever enough it sees that *fn-name*
is a constant and thus can replace each occurence in the
body with the string.


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