Hi,

I am having hard time writing a macro in cljc which uses core.async/go 
macro. 

Minimal project that illustrates the problem is here 
<https://github.com/vspinu/clj-problems/tree/cljs-undefined>.  In a 
nutshell:

core.clj:

(ns cljproj.core
  (:require
   #?(:clj  [clojure.core.async :refer [go >! <!]]
      :cljs [cljs.core.async :as a :refer [>! <!]]))
  #?(:cljs
     (:require-macros
      [cljproj.core]
      [cljs.core.async.macros :as am :refer [go]])))

(defmacro tt [ch]
  `(go (println (<! ~ch))))




dep.clj:

(ns cljproj.dep
  (:require
   [clojure.core.async :as a]
   [cljproj.core :refer [tt]]))

(defn pp []
  (tt (a/chan)))




When dep.clj is compiled (./build.sh) the following warning shows:

WARNING: Use of undeclared Var cljs.core.async/go at line 7 src/cljproj/dep.
cljc

At the repl (./node_repl.sh) the above `pp` function throws `Cannot read 
property 'call' of undefined` because `tt` expands into 


cljproj.dep> (macroexpand-1 '(tt (a/chan)))
(clojure.core.async/go (clojure.core/println (clojure.core.async/<! 
(a/chan))))

So, that reference to `go` expands into `clojure.core.async/go` instead of 
the `cljs.core.async.macro/go`. 

Is this a bug or I am doing something wrong here? What is the canonical way 
to require async in cljc files?

Many thanks!

  Vitalie

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to