Regarding current function, Stephen posted this code a whie ago so I
don't think he'll mind me regurgitating it for you:

(use 'clojure.contrib.str-utils)

; Stephen C. Gilardi

(defn unmangle

  "Given the name of a class that implements a Clojure function,

  returns the function's name in Clojure.

  Note: If the true Clojure function name contains any underscores

  (a rare occurrence), the unmangled name will contain hyphens

  at those locations instead."

  [class-name]

  (.replace

    (re-sub #"^(.+)\$(.+)__\d+$" "$1/$2" class-name)

    \_ \-))



; Stephen C. Gilardi

(defmacro current-function-name

  "Returns a string, the name of the current Clojure function."

  []

  `(-> (Throwable.) .getStackTrace first .getClassName unmangle))


I imagine some similar unmangling could be applied to getting the
class-name of an arbitrary function, something like
(unmangle (.toString foo))  ;; but not exactly - this doesn't work
 - if you figure that out please post the answer :)


Regards,
Tim.

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

Reply via email to