Re: Re: Re: How to determine a function name at runtime

2011-04-29 Thread Ken Wesson
On Fri, Apr 29, 2011 at 3:27 AM, Meikel Brandmeyer wrote: > Hi, > > Am Freitag, 29. April 2011 08:43:10 UTC+2 schrieb Ken Wesson: >> >> Yeah, that works if you have the object in hand and it's not wrapped >> or anything. Of course it has the same problem: which component are >> you interested in?

Aw: Re: Re: How to determine a function name at runtime

2011-04-29 Thread Meikel Brandmeyer
Hi, Am Freitag, 29. April 2011 08:43:10 UTC+2 schrieb Ken Wesson: > Yeah, that works if you have the object in hand and it's not wrapped > or anything. Of course it has the same problem: which component are > you interested in? I guess in this case you might strip everything > before the last $,

Re: Re: How to determine a function name at runtime

2011-04-28 Thread Ken Wesson
On Fri, Apr 29, 2011 at 2:06 AM, Meikel Brandmeyer wrote: > Hi, > > or just use the class name, which is what the stacktrace gives you anyway. > > user=> (class (fn [x] x)) > user$eval1$fn__2 > user=> (class (fn foo [x] x)) > user$eval5$foo__6 > user=> (defn bar [x] x) > #'user/bar > user=> (class

Aw: Re: How to determine a function name at runtime

2011-04-28 Thread Meikel Brandmeyer
Hi, or just use the class name, which is what the stacktrace gives you anyway. user=> (class (fn [x] x)) user$eval1$fn__2 user=> (class (fn foo [x] x)) user$eval5$foo__6 user=> (defn bar [x] x) #'user/bar user=> (class bar) user$bar user=> (defn frob [f] (prn (class f))) #'user/frob user=> (frob

Re: How to determine a function name at runtime

2011-04-28 Thread Ken Wesson
On Thu, Apr 28, 2011 at 6:36 AM, MohanR wrote: > There should be a way to print the currently executing function and > the calling function logging purposes ? > > I believe Java has StackTraceElement[] to do this. And therefore so does Clojure: user=> ((fn foo [] (map #(.getClassName %) (.getSta

Re: How to determine a function name at runtime

2011-04-28 Thread MohanR
There should be a way to print the currently executing function and the calling function logging purposes ? I believe Java has StackTraceElement[] to do this. Thanks, Mohan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: How to determine a function name at runtime

2011-04-26 Thread James Reeves
On 27 April 2011 01:09, Ken Wesson wrote: > It has some limitations, though. Specifically, it won't work with > local functions, even named ones: Yes, good point! A more foolproof way might be to use a macro, but then macros have their own disadvantages. It depends on what clj123123 wants to us

Re: How to determine a function name at runtime

2011-04-26 Thread Ken Wesson
On Tue, Apr 26, 2011 at 7:18 PM, clj123123 wrote: > Thank you James, this worked for me. > > On Apr 26, 4:11 pm, James Reeves wrote: >> On 27 April 2011 00:05, clj123123 wrote: >> >> > I have a function: >> >> > (defn abc [] (println "blah")) >> >> > (defn blah2 [f] (println f)) >> >> > (blah2 a

Re: How to determine a function name at runtime

2011-04-26 Thread clj123123
Thank you James, this worked for me. On Apr 26, 4:11 pm, James Reeves wrote: > On 27 April 2011 00:05, clj123123 wrote: > > > I have a function: > > > (defn abc [] (println "blah")) > > > (defn blah2 [f] (println f)) > > > (blah2 abc) > > > I need to print out the name of the function passed to

Re: How to determine a function name at runtime

2011-04-26 Thread James Reeves
On 27 April 2011 00:05, clj123123 wrote: > I have a function: > > (defn abc [] (println "blah")) > > (defn blah2 [f] (println f)) > > (blah2 abc) > > I need to print out the name of the function passed to blah2. Then you want something like: (defn blah2 [f] (println (:name (meta f - James

How to determine a function name at runtime

2011-04-26 Thread clj123123
I have a function: (defn abc [] (println "blah")) (defn blah2 [f] (println f)) (blah2 abc) I need to print out the name of the function passed to blah2. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@g