Skip to content

Instantly share code, notes, and snippets.

@sritchie
Created March 31, 2011 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sritchie/897167 to your computer and use it in GitHub Desktop.
Save sritchie/897167 to your computer and use it in GitHub Desktop.
(defmacro defthreader [macro-name & rest]
(let [[macro-name [check-func]] (name-with-attributes macro-name rest)]
`(defmacro ~macro-name
([argvec#] (~macro-name argvec# identity))
([argvec# subphase# & left#]
`(fn [~'session# ~@argvec#]
(--> ~'session#
~subphase#
(~~check-func (str "The threaded argument passed out of " '~subphase#))
~@(when left#
[`((~'macro-name ~argvec# ~@left#) ~@argvec#)])))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment