Skip to content

Instantly share code, notes, and snippets.

@mowat27
Created February 24, 2012 09:06
Show Gist options
  • Save mowat27/1899666 to your computer and use it in GitHub Desktop.
Save mowat27/1899666 to your computer and use it in GitHub Desktop.
Example of using a macro to rewrite defn in Clojure
(ns homoiconic.my-defn)
; ----------- --- --- -- -- - -
(defn hello [what]
(str "hello " what))
(hello "world")
; ----------- --- --- -- -- - -
(defmacro my-defn [form args name]
`(defn ~name ~args ~form))
(my-defn
(str "HELLO " what)
[what] my-hello)
(my-hello "world")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment