Thanks Timothy/Stephen, that was very useful to me :)

Op zondag 20 december 2009 23:50:05 UTC+1 schreef Timothy Pratley:
>
> 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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to