On Sat, Nov 8, 2008 at 8:31 PM, Stuart Halloway
<[EMAIL PROTECTED]> wrote:
>
> (defmacro defrunonce [sym doc & forms]
>   "Defines a function with runonce semantics. Curren run status
>   is kept in a reference under the :has-run metadata key."
>   (let [[function has-run] (runonce (eval (concat (list 'fn [])
> forms)))]
>     `(def ~(with-meta sym {:has-run has-run}) ~function)))

(defmacro defrunonce [sym doc & forms]
  "Defines a function with runonce semantics. Curren run status
  is kept in a reference under the :has-run metadata key."
  (let [has-run (gensym)]
    `(let [[function# ~has-run] (runonce (fn [] [EMAIL PROTECTED]))]
       (def ~(with-meta sym {:has-run has-run}) function#))))

--Chouser

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to