Consider that:
(defn add [a b] (+ a b))
is expanded to (something like):
(def add (fn [a b] (+ a b)))
So the actual code that runs is an anonymous function, which is bound to
the (global) var #'add -- the function itself has no name.
dev=> (*macroexpand* '(*defn* *add* [a b] (*+* a b)))
(def
Well, it seems like it should be possible. At the end of the defn macro,
metadata is attached to a function, so you can see the name with:
```
(meta #'my.ns/add)
```
And you could do this inside the function:
```
(defn add [a b]
(let [name (:name (meta #'add))]
(str a b name)))
```
But th
How get function name in body?
(defn add [a b]
;; how get "add" here?
(+ a b))
--
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 b