On Wed, Mar 28, 2012 at 3:30 PM, Rostislav Svoboda
<rostislav.svob...@gmail.com> wrote:
>> Steve – Your example is already compact, but maybe it can be made even
>> cheaper by specifying maxDepth of 1:
>> http://docs.oracle.com/javase/6/docs/api/java/lang/management/ThreadMXBean.html#getThreadInfo(long,
>> int)
>
> @Shantanu: What about the defn0 macro from Steve:
>
> (defmacro defn0 [name & fdcls]
>  `(let [~'%0 (symbol (name (ns-name *ns*)) (name '~name))]
>    (defn ~name ~@fdcls)))
>
> (defn0 foo [a b]
>    (println "Running function"%0 ":" (+ a b)))
>
> user=> (foo 1 2)
> Running function user/foo : 3
> nil
>
> Is't it what do you need?

He wants to be able to use plain defn, which suggests

(defmacro defn [name & other-args]
  `(let [~'current-fn '~name]
     (clojure.core/defn ~name ~@other-args)))

...

(defn foo [x y]
  (println current-fn)
  (+ x y))

user=> (foo 3 4)
foo
7
user=>

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to