It's a good start.

You could next import clojure.lang.Compiler and call the static method
demunge like so on the output "cool_func_BANG_"
(Compiler/demunge "cool_func_BANG_") ; => "cool-func!"

On Tue, Oct 24, 2017 at 11:27 AM, Shantanu Kumar <kumar.shant...@gmail.com>
wrote:

> Not sure whether you can deterministically recover the exact name at all
> times, but the following can get you started:
>
> (re-matches #".*\$(.*)__.*" (.getName (class (fn cool-func! [] (println
> "hi")))))
>
> I have altered the name to `cool-func!` on purpose to show where it may
> break.
>
>
> Shantanu
>
>
> On Tuesday, 24 October 2017 10:35:12 UTC+5:30, Nick Mudge wrote:
>>
>> Let's say I have this anonymous function:
>>
>> (fn cool [] (println "hi"))
>>
>> How can I extract the name from it?
>>
>> Obviously the name of the function is stored with the function. How can I
>> get to it?
>>
>>
>> --
> 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/d/optout.
>

-- 
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/d/optout.

Reply via email to