Since you want to use the plain defn, what about thinking in a different
way ?
Write a macro like `with-function-name`, wraps the function call instead
of the function definition.
(defmacro with-function-name [fn-name args]
...)
In clojure, because you can assign function to a var at any time. So the
wrapped defn could not always work.
For example:
(defn* plus [a b] ...)
(def plus-alias plus)
Then you will call plus-alias but got the name as plus. I know this is a
special case, but it's actually there.
On 03/28/2012 11:02 PM, Shantanu Kumar wrote:
Hi,
Is it possible to write a macro that when used in a top-level function
(created using defn) can find out the name of the immediate top-level
function? I know *ns* returns the namespace and it's possible to walk
the current thread's stack trace to find out the function name, but I
am looking for a computationally cheap way to do it.
Thanks,
Shantanu
--
Sun Ning
Software developer
Nanjing, China (N32°3'42'' E118°46'40'')
http://about.me/sunng/bio
--
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