This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-25
Channels
- # announcements (4)
- # babashka (13)
- # beginners (115)
- # cider (62)
- # clj-kondo (16)
- # cljdoc (4)
- # cljs-dev (5)
- # clojure (44)
- # clojure-europe (57)
- # clojure-greece (1)
- # clojure-italy (2)
- # clojure-nl (3)
- # clojure-spec (2)
- # clojure-uk (24)
- # clojurescript (58)
- # code-reviews (2)
- # community-development (6)
- # conjure (3)
- # core-async (9)
- # cursive (34)
- # datahike (3)
- # datalog (1)
- # datomic (67)
- # emacs (9)
- # events (5)
- # fulcro (9)
- # graalvm (1)
- # jobs (1)
- # lsp (24)
- # off-topic (20)
- # pathom (17)
- # polylith (11)
- # re-frame (21)
- # react (21)
- # reagent (3)
- # reitit (23)
- # releases (1)
- # remote-jobs (1)
- # ring (3)
- # sci (47)
- # tools-deps (7)
- # vim (15)
- # xtdb (4)
is there some convenient way to macro expand go blocks? Can't figure out how to propagate the env correctly
What do you mean by “convenient”? Regular macroexpand works, but the output is quite…. verbose.
(macroexpand-1
'(clojure.core.async/go
(let [ret (clojure.core.async/<! (clojure.core.async/go :hello))]
(println ret))))
There's macroexpand-all from clojure.walk
> Can't figure out how to propagate the env correctly > Now try binding a channel outside the go block what behavior are you seeing? in macro expansion, a binding from outside the block should just show up as opaque
is it this error?
Syntax error macroexpanding >/go at (REPL:1:1).
Could not resolve var: c
this is because go
does some "clever" code rewriting, in my experience it doesn't take much to confuse it
(ins)user=> (require '[clojure.core.async :as >])
nil
(ins)user=> (macroexpand '(let [c (>/chan)] (>/go (let [ret (>/<! (>/go (>/<! c)))] (println ret)))))
(let* [c (>/chan)] (>/go (let [ret (>/<! (>/go (>/<! c)))] (println ret))))
(ins)user=> (require '[clojure.walk :refer [macroexpand-all]])
nil
(ins)user=> (macroexpand-all '(let [c (>/chan)] (>/go (let [ret (>/<! (>/go (>/<! c)))] (println ret)))))
Syntax error macroexpanding >/go at (REPL:1:1).
Could not resolve var: c
*edit: added more context to the error messageI think that's what's going on here at least