Skip to content

Instantly share code, notes, and snippets.

@mattdeboard
Created September 5, 2012 01:19
Show Gist options
  • Select an option

  • Save mattdeboard/3628843 to your computer and use it in GitHub Desktop.

Select an option

Save mattdeboard/3628843 to your computer and use it in GitHub Desktop.
(defmacro proxy-meta
"This macro emits a function that can then be called with the appropriate
args to proxy a given class, extending it to implement the `IObj' interface.
"
[class]
`(fn make#
[infile# & [moremeta#]]
(let [metadata# (merge {:filename infile#} moremeta#)]
(proxy [~class clojure.lang.IObj] [infile#]
(withMeta [newmeta#] (make# infile# newmeta#))
(meta [] metadata#)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment