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 ar
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
s, LLC. -- https://worldsinglesnetworks.com/
"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
On Wed, Apr 28, 2021 at 6:35 AM damon kwok wrote:
>
> How get function name in body?
>
> (defn add [a b]
> ;; how get "add&q
> De: "Sean Corfield"
> À: "clojure"
> Envoyé: Jeudi 29 Avril 2021 01:26:34
> Objet: Re: How get function name in body?
> Consider that:
> (defn add [a b] (+ a b))
> is expanded to (something like):
> (def add (fn [a b] (+ a b)))
> So the
v=>
Thanks, Rémi!
On Thu, Apr 29, 2021 at 12:08 PM Remi Forax wrote:
>
>
> --
>
> *De: *"Sean Corfield"
> *À: *"clojure"
> *Envoyé: *Jeudi 29 Avril 2021 01:26:34
> *Objet: *Re: How get function name in body?
>
> Con
+* a b))
>
> #'dev/add
>
> dev=> (add 1 2)
>
> dev/add
>
> 3
>
> dev=>
>
> Thanks, Rémi!
>
> On Thu, Apr 29, 2021 at 12:08 PM Remi Forax wrote:
>
>>
>>
>> ----------
>>
>> *De: *"Sean Corfie
;
>>
>> Thanks, Rémi!
>>
>> On Thu, Apr 29, 2021 at 12:08 PM Remi Forax wrote:
>>
>>>
>>>
>>> --
>>>
>>> *De: *"Sean Corfield"
>>> *À: *"clojure"
>>> *Envo
ang.StackWalker$Option*
>>> /RETAIN_CLASS_REFERENCE)
>>>
>>> #_=> (*+* a b))
>>>
>>> #'dev/add
>>>
>>> dev=> (add 1 2)
>>>
>>> dev/add
>>>
>>> 3
>>>
>>> de
Class* (
>>>> *java.lang.StackWalker*/getInstance *java.lang.StackWalker$Option*
>>>> /RETAIN_CLASS_REFERENCE)
>>>>
>>>> #_=> (*+* a b))
>>>>
>>>> #'dev/add
>>>>
>>>> dev=> (add 1 2)
>