I want to write a macro that defines a function like `defn` but also on each 
function call, prints the values of the arguments passed to the function.

Is there a  generic way in `cljs` inside a macro, to get the value of the 
arguments passed to a function, something like javascript `arguments` object.

I've found a hack using (js* "arguments") :

(defmacro defprint [& definition]
  (let [[func-name args & body] definition]
    `(defn ~func-name ~args
       (print (cljs.core/vals (cljs.core/js->clj (~'js* "arguments"))))
       ~@body)))


(defprint foot-print [x] )
(foot-print 9); prints (9)

Is there a more elegant way to do that?

Remark:
My code almost works fine with special arguments declaration:

(defprint blue-print [& args])
(blue-print 9); prints ((9))

This is because the js function that is created receives only a single argument.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to