Skip to content

Instantly share code, notes, and snippets.

Created January 10, 2012 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save anonymous/1590658 to your computer and use it in GitHub Desktop.
Save anonymous/1590658 to your computer and use it in GitHub Desktop.
ugly macro
(defmacro defcontroller [name & actions]
(let [iname (symbol (str "I" (str name)))
methods (for [[m as & fs] actions] `(~m ~(vec (cons 'this as)) ~@fs))
sigs (for [[m as & fs] methods] `(~m ~(vec as)))]
`(do
(defprotocol ~iname ~@sigs)
(deftype
~name
[]
~iname
~@(for [[m as & fs] methods]
(let [z `(~m ~as ~@fs)] `(~(with-meta `(~@z) {:tag "test"}))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment