Hi, Am 13.06.2009 um 23:02 schrieb Wrexsoul:
Now I'm working on some Swing code and came up with these, which are obviously going to be useful:
And which are partly in clojure.contrib.swing-utils :)
(defmacro do-on-edt [& body]
`(SwingUtilities/invokeLater #(do ~...@body)))
(defmacro get-on-edt [& body]
`(let [ret# (atom nil)]
(SwingUtilities/invokeLater #(reset! ret# [(do ~...@body)]))
(loop []
(let [r# @ret#]
(if r#
(first r#)
(recur))))))
And while we are talking about macro design and
transferring return values between threads:
(defn get-on-edt*
[thunk]
(let [ret (atom nil)]
(SwingUtitilities/invokeAndWait #(reset! ret (thunk)))
@ret))
(defmacro get-on-edt
[& body]
`(get-on-edt* (fn [] ~body)))
Don't know if anyone else here is familiar with dotted-pair notation though, except clojure's author.
And please tune down the rhetoric. This is not the level on which things are discussed in this group. Sincerely Meikel
smime.p7s
Description: S/MIME cryptographic signature
