On Jul 8, 2009, at 9:11 AM, Mike wrote:

What I'm missing is why I can't print a function.  I understand that
most of the functions I write use quite a few macros, and after
expansion into the core forms it looks shredded...but isn't there any
way for me to see a representation of this "source" after a function
has been compiled?

For instance,

(def a #(+ %1 %2))
#'user/a
a
#<user$a__3 user$a...@a141e>

Isn't there any way for me to get something like

(deep-print a)
(fn [arg1 arg2] (*built-in-+* arg1 arg2))

or whatever that anonymous lambda would actually evaluate to?

Once it's compiled, it's JVM bytecode. I'm not aware of a tool that could decompile it into Clojure code, even in a low-level form. If you want to see the full expansion of a function while you still have its source, you can use mexpand-all from clojure.contrib.macro-utils:

Clojure 1.1.0-alpha-SNAPSHOT
user=> (use 'clojure.contrib.macro-utils)
nil
user=> (mexpand-all '#(+ %1 %2))
(fn* ([p1__1432 p2__1433] (+ p1__1432 p2__1433)))
user=>

That output contains no macro calls.

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to