leonoel / cloroutine

Coroutine support for clojure
Eclipse Public License 2.0
228 stars 10 forks source link

Generator example is completely lazy #22

Closed joshlemer closed 2 years ago

joshlemer commented 2 years ago

In the given Generator example implementation, the generator strictly evaluates up until and including the first element as soon as it's deefined. For instance

(def foo (generate (println "hi") (yield 1)))
;; "hi" is printed already, before forcing foo

Now, with the proposed changes, the generator is completely lazy, including the first element.