This question is tricky to answer, do to the way things are bound in Clojure.
It is possible to get the name of a the symbol the fn is bound to, but the fn object itself has no name. Also, fn objects can't take metadata (but this is supposed to be fixed eventually), so what you are looking for isn't possible in native Clojure. Sean On Dec 20, 4:55 pm, David Cabana <[email protected]> wrote: > Suppose we define a function called sq: > > (defn sq [x] > (do (println "sq") > (* x x))) > > I wanted sq to print it's own name when run; to make it do so I > inserted the name as a string. > Is there some way to dynamically determine the name and so avoid using > the string? > > Similarly, is it possible to define a function name-of so that > (name-of sq) returns "sq", etc ? > > Thank you, > drc -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
