没有 Clojure 社区可发,那就这儿吧.. 话说我一直 Ruby 就 Ruby 吧... 看样子是用 Clojure 的语法跑 Ruby,, https://github.com/unnali/rouge
; define a macro
(defmacro defn [name args & body]
`(def ~name (fn ~name ~args ~@body)))
; call a Ruby method on Kernel (if the ruby namespace is referred)
(defn require [lib]
(.require Kernel lib))
; call a Ruby method on an Array with a block argument
(defn reduce [f coll]
(.inject coll | f))
; using Ruby's AMQP gem with an inline block
(.subscribe queue {:ack true} | [metadata payload]
(puts (str "got a message: " payload))
(.ack metadata))
; copied from core.clj and modified to work with our currently smaller core
(defmacro binding [bindings & body]
(let [var-ize (fn [var-vals]
(.flatten
(map
(fn [pair]
(let [key (first pair)
val (second pair)]
[`(.name (var ~key)) val]))
(.each_slice var-vals 2))
1))]
`(try
(push-thread-bindings (hash-map ~@(var-ize bindings)))
~@body
(finally
(pop-thread-bindings)))))