Skip to content

Instantly share code, notes, and snippets.

@catharinejm
Created November 19, 2014 14:23
Show Gist options
  • Select an option

  • Save catharinejm/f8c03840c5b74dbff44d to your computer and use it in GitHub Desktop.

Select an option

Save catharinejm/f8c03840c5b74dbff44d to your computer and use it in GitHub Desktop.
bitwise op shorthand, with metadata (inline!) from originals
(defmacro bit-ops
[]
`(do
~@(for [[s l] '[[<< bit-shift-left]
[>> bit-shift-right]
[>>> unsigned-bit-shift-right]
[| bit-or]
[& bit-and]
[xor bit-xor]
[!b bit-not]]]
`(do
(def ~s ~(deref (resolve l)))
(.setMeta (var ~s) (meta ~(resolve l)))))))
(bit-ops)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment