Advertisement
Guest User

with-source-code

a guest
Jan 5th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.29 KB | None | 0 0
  1. (defmacro with-source-code [[defsym name & body :as form]]
  2.   `(def ~(with-meta name {:source-code (first `('~form))}) ~(var-get (eval form))))
  3.  
  4. (defmacro get-source-code [var-name] `(:source-code (meta (var ~var-name))))
  5.  
  6. (with-source-code (defn foobar [x y] (/ x y)))
  7.  
  8. (get-source-code foobar)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement