How get function name in body?

2021-04-28 Thread damon kwok
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

Re: How get function name in body?

2021-04-28 Thread Blake Watson
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

Re: How get function name in body?

2021-04-28 Thread Sean Corfield
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

Re: How get function name in body?

2021-04-29 Thread Remi Forax
> 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

Re: How get function name in body?

2021-04-29 Thread Sean Corfield
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

Re: How get function name in body?

2021-04-29 Thread damon kwok
+* 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

Re: How get function name in body?

2021-04-29 Thread Sean Corfield
; >> >> Thanks, Rémi! >> >> On Thu, Apr 29, 2021 at 12:08 PM Remi Forax wrote: >> >>> >>> >>> -- >>> >>> *De: *"Sean Corfield" >>> *À: *"clojure" >>> *Envo

Re: How get function name in body?

2021-05-03 Thread Justin Smith
ang.StackWalker$Option* >>> /RETAIN_CLASS_REFERENCE) >>> >>> #_=> (*+* a b)) >>> >>> #'dev/add >>> >>> dev=> (add 1 2) >>> >>> dev/add >>> >>> 3 >>> >>> de

Re: How get function name in body?

2021-05-04 Thread Brent Millare
Class* ( >>>> *java.lang.StackWalker*/getInstance *java.lang.StackWalker$Option* >>>> /RETAIN_CLASS_REFERENCE) >>>> >>>> #_=> (*+* a b)) >>>> >>>> #'dev/add >>>> >>>> dev=> (add 1 2) >