Don't Laugh - How to Get the Name of an Anonymous Function

2017-10-23 Thread Nick Mudge
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

Re: Don't Laugh - How to Get the Name of an Anonymous Function

2017-10-23 Thread Shantanu Kumar
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