Re: Name of a function

2015-02-15 Thread Cecil Westerhof
2015-02-14 20:23 GMT+01:00 Steve Miner stevemi...@gmail.com: Clojure doesn't give you direct access to the name of the function you're defining. However, you could use a macro to get that. Here’s one way. This macro binds the strange symbol %0 to the symbol naming the current function

Name of a function

2015-02-14 Thread Cecil Westerhof
In Bash I use the following construct: printf ${FUNCNAME} needs an expression\n In this way I do not have to change the print statement when the name of the function changes. Is something like this also possible in clojure? -- Cecil Westerhof -- You received this message because you

Re: Name of a function

2015-02-14 Thread Cecil Westerhof
to use the function name in the throw. So that when I change the function name to round-long, I do not need to change the throw statement, because the name of the function is automatically filled. ​ On Saturday, 14 February 2015 16:11:48 UTC, Cecil Westerhof wrote: In Bash I use the following

Re: Name of a function

2015-02-14 Thread Jony Hudson
Unless I'm mistaken, in the output you show: Exception ERROR: round [:high|:low|:normal] VALUE user/round (repl-startup.clj:30)​ user/round is the name of the function, as desired. Jony On Saturday, 14 February 2015 19:09:53 UTC, Cecil Westerhof wrote: 2015-02-14 20:03 GMT+01:00 Jony

Re: Name of a function

2015-02-14 Thread Jony Hudson
when the name of the function changes. Is something like this also possible in clojure? -- Cecil Westerhof -- 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

Re: Name of a function

2015-02-14 Thread Jony Hudson
Ah, I see. I don't know how to do that. But, the function name should be in the stack trace associated with the exception. Is there a particular reason you also want to put it in the message? Jony On Saturday, 14 February 2015 18:45:12 UTC, Cecil Westerhof wrote: 2015-02-14 18:58 GMT+01

Re: Name of a function

2015-02-14 Thread Cecil Westerhof
2015-02-14 20:03 GMT+01:00 Jony Hudson jonyepsi...@gmail.com: Ah, I see. I don't know how to do that. But, the function name should be in the stack trace associated with the exception. Is there a particular reason you also want to put it in the message? ​Well if I enter in the REPL

Re: Name of a function

2015-02-14 Thread Herwig Hochleitner
Well, one of the many reasons, that clojure is faster than bash is, that during compilation, code is divorced from the original source symbols. That means you can only access information about the original source that you, or some library code you use, put in there for you. Jony stated correctly,

Re: Name of a function

2015-02-14 Thread Steve Miner
Clojure doesn't give you direct access to the name of the function you're defining. However, you could use a macro to get that. Here’s one way. This macro binds the strange symbol %0 to the symbol naming the current function. ;; %0 is bound to the function's symbolic name within

Re: Name of a function

2015-02-14 Thread Shantanu Kumar
: printf ${FUNCNAME} needs an expression\n In this way I do not have to change the print statement when the name of the function changes. Is something like this also possible in clojure? -- Cecil Westerhof -- You received this message because you are subscribed to the Google Groups Clojure

Re: Name of a function

2015-02-14 Thread Shantanu Kumar
UTC+5:30, Cecil Westerhof wrote: In Bash I use the following construct: printf ${FUNCNAME} needs an expression\n In this way I do not have to change the print statement when the name of the function changes. Is something like this also possible in clojure? -- Cecil Westerhof

Re: Name of a function

2015-02-14 Thread Cecil Westerhof
2015-02-14 20:21 GMT+01:00 Jony Hudson jonyepsi...@gmail.com: Unless I'm mistaken, in the output you show: Exception ERROR: round [:high|:low|:normal] VALUE user/round (repl-startup.clj:30)​ user/round is the name of the function, as desired. ​You are right: I was not looking correctly

name of current function

2009-05-03 Thread Mark Volkmann
Is there a special variable that holds the name of the currently running function so it can be output in a logging message? I'm thinking of something like this: (defn my-function [] (println entered *current-function*) ... ) -- R. Mark Volkmann Object Computing, Inc.

Re: name of current function

2009-05-03 Thread e
you might already have this way ... but probably only during debug since it throws an exception and parses it. http://forums.sun.com/thread.jspa?threadID=548409start=0 that page also mentions something that sounds better: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StackTraceElement.html

Re: name of current function

2009-05-03 Thread Stephen C. Gilardi
such a var by updating its value on every function entry would be prohibitively expensive in runtime in the general case. As e mentioned, it's possible to use the exception system to get the name of the current function in a particular case. Here's an example: [debug_utils.clj] (ns

Re: name of current function [corrected]

2009-05-03 Thread Stephen C. Gilardi
[clojure.contrib.str-utils :only (re-sub)])) (defn unmangle Given the name of a class that implements a Clojure function, returns the function's name in Clojure. Note: If the true Clojure function name contains any underscores (a rare occurrence), the unmangled name will contain hyphens

Re: name of current function

2009-05-03 Thread André Thieme
On 3 Mai, 15:58, Mark Volkmann r.mark.volkm...@gmail.com wrote: Is there a special variable that holds the name of the currently running function so it can be output in a logging message? I'm thinking of something like this: (defn my-function []   (println entered *current-function*)