 (ns conexp.contrib.generators
-  (:use [clojure.contrib.macro-utils :only (macrolet)])
   (:use [clojure.contrib.def])
   (:import [java.util.concurrent SynchronousQueue]
 	   [java.util NoSuchElementException]))

    (runner)))

(defmacro generate-by
  ""
  [function & args]
  `(generate (apply (make-generator ~function) '~args)))

nil

		(java.util.NoSuchElementException. "No more elements to generate."))
	       next#)))))))

(defmacro- defg
  "Globally def'ines a generator. When given some arguments a function
  is returned yielding all \"yield\"ed values on subsequent calls."
  [name args & body]
  `(defn ~name [& args#]
     (let [gen# (make-generator (fn ~name ~args ~@body))]
       (apply gen# args#))))

(defn- generate
  "Collects all values generated by the generator into a lazy sequence."
  [generator]
  (let [eos (gensym),
	runner (fn runner []
