Skip to content

Instantly share code, notes, and snippets.

@hiredman
Created November 11, 2010 05:26
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 hiredman/672059 to your computer and use it in GitHub Desktop.
Save hiredman/672059 to your computer and use it in GitHub Desktop.
(defprotocol Bindable
(bind [thing]))
(defmacro blet [bindings & body]
(let [names (take-nth 2 bindings)
values (map (fn [v] `(bind ~v))
(take-nth 2 (rest bindings)))
bindings (vec (interleave names values))]
`(let ~bindings
~@body)))
(extend-type Object
Bindable
(bind [thing] thing))
(extend-type clojure.lang.IDeref
Bindable
(bind [thing] @thing))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment