Welcome! Please see the About page for a little more info on how this works.

+1 vote
in core.async by

The following snippet fails because <! is outside of {{go}} boundaries.

`
(let [port (a/chan)]
(a/go

(letfn [(my-even? [n] (if (zero? n) true (my-odd? (dec n))))
        (my-odd? [n] (if (zero? n) false (my-even? (dec n))))]
  (my-even? (a/<! port)))))

`

Async code in {{letfn}} body should be rewritten by the {{go}} macro, given all bound functions can be properly initialized when the body starts.

5 Answers

0 votes
by

Comment made by: bronsa

Removing bad patch

0 votes
by

Comment made by: alexmiller

What's the status on this? 0001-ASYNC-221-handle-letfn-in-ioc+test.patch is the patch?

0 votes
by

Comment made by: leonoel

No, the fix and the test are both wrong.
The fix doesn't properly establishes circular references and the test fails to check it because it shadows clojure.core's odd?/even?.

0 votes
by

Comment made by: leonoel

Updated example to properly check circular references

0 votes
by
Reference: https://clojure.atlassian.net/browse/ASYNC-221 (reported by leonoel)
...