leonoel / cloroutine

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

Incorrect compilation of loop form #10

Closed darkleaf closed 4 years ago

darkleaf commented 4 years ago
(ns example
  (:require
   [cloroutine.core :refer [cr]]))

(defn example []
  (cr {}
      (let [initial 0]
        (loop [i initial]
          (prn initial)
          (let [i (inc initial)]
            (if (< initial 10)
              (recur i)
              i))))))

(let [coroutine (example)]
  (coroutine))    

stdout:

0
1
2
3
4
5
6
7
8
9
10

A value of initial binding is changing unexpectable. Without cr this code should continuously print 0.

leonoel commented 4 years ago

Fixed in version 9.

darkleaf commented 4 years ago

Thanks!