

core.async: "Can't recur here" in ClojureScript but OK in Clojure
source link: https://blog.jakubholy.net/2014/05/12/core-async-cant-recur-here-in-clojurescript-but-ok-in-clojure/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

core.async: "Can't recur here" in ClojureScript but OK in Clojure
core.async "0.1.303.0-886421-alpha"
and clojurescript "0.0-2202"
as well as the older core.async "0.1.267.0-0d7780-alpha"
and clojurescript "0.0-2173"
), the following function compiles just fine in Clojure but fails in ClojureScript:
(defn cljs-cannot-recur! []
(go-loop [v nil]
(when-let [next-val (<! (timeout 300))]
(recur next-val))))
The error in ClojureScript is
clojure.lang.ExceptionInfo: Can't recur here at line 23 /my/path/core.cljs ::
{:tag :cljs/analysis-error, :file "/my/path/core.cljs", :line 23, :column 7}
core.clj:4403 clojure.core/ex-info
... // very long stacktrace of 0 value
Workaround: replace
(go-loop ..)
with (go (loop ..))
.Another fun fact: ClojureScript's core.async lacks (at least) alt! (I did work around it by using alts! so it is not a show-stopper but still the difference is irritating and I fail to understand why it is missing.)
Oh, joy!
Are you benefitting from my writing? Consider buying me a coffee or supporting my work via GitHub Sponsors. Thank you! You can also book me for a mentoring / pair-programming session via Codementor or (cheaper) email.
Allow me to write to you!
Let's get in touch! I will occasionally send you a short email with a few links to interesting stuff I found and with summaries of my new blog posts. Max 1-2 emails per month. I read and answer to all replies.
Recommend
-
36
Build your productivity tools with org-mode
-
13
Journal 2020.1 - Clojure survey, core.async Happy new year! core.async I spent some time with core.async this week, trying to clear up a bunch of old patches and tickets. Many thanks to Kevin Downey, Ni...
-
19
ClojureConj 2017 Baltimore: Learning Clojure and ClojureScript by Playing a Card Game video07 Nov 2017 At ClojureConj 2017 I gave a talk titled: "Learning Clojure and ClojureScript by Playing a Card Game". The recording o...
-
8
The power and danger of deftype in clojure and clojurescript Apr 26, 2016 • Yehonathan Sharvit In clojure, records, types and protocols are parts of the fundamental...
-
14
Playing "Racket Gin Rummy in ClojureScript" with Clojure01 Jun 2012 In 2010 I built my first real Clojure application. It was a tool to execute semantic specifications of modeling languages and was part of my master thesis....
-
6
从Clojure/ClojureScript迁移到Rust:体积小4倍性能快50倍 - asciinema asciinema-player 已经在 JavaScript 和 Rust 中从头开始重新实现,使虚拟终端解释器的速度提高了 50 倍,同时将 JS 包的大小减少了 4 倍。是什么促使我们要改变了之前的...
-
9
Playing "Racket Gin Rummy in ClojureScript" with Clojure01 Jun 2012 In 2010 I built my first real Clojure application. It was a tool to execute semantic specifications of modeling languages and was part of my master thesis....
-
9
ClojureConj 2017 Baltimore: Learning Clojure and ClojureScript by Playing a Card Game video07 Nov 2017 At ClojureConj 2017 I gave a talk titled: "Learning Clojure and ClojureScript by Playing a Card Game". The recording o...
-
6
Maya Shiff November 30, 2022 1 minute read ...
-
3
Conversation Member...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK