Sorry I posted this here, wasn't aware of clojurescript group. Found a similar posting(almost a clone) here <https://groups.google.com/forum/#!searchin/clojurescript/macro|sort:relevance/clojurescript/HsWTuhMP7yc/kr1AARDzAwAJ> with a useful hack here <https://github.com/tonsky/datascript/blob/master/src/datascript/arrays.cljc>
On Friday, March 17, 2017 at 1:37:27 PM UTC+1, Arewa Olakunle wrote: > > I have been trying to define a macro for clojurescript/clojure using a > cljc file > > (ns async > (:require #?(:clj [clojure.core.async :as a :refer [go-loop]]) > #?@(:cljs [[cljs.core.async :as a] > [cljs.core.async.macros :refer [go-loop]]]))) > > (defmacro dochan > "Wrap the expressions in a go-loop over the single binding to a channel > till the chan closes" > [chan & body] > (let [[name channel-expr] binding] > `(let [channel# ~channel-expr] > (a/go-loop [~name (a/<! channel#)] > (if (some? ~name) > (do > ~@body > (recur (a/<! channel#))) > (a/close! channel#)))))) > ;; in CLJS > (ns cljs > (:require [cljs.core.async :as a])) > > (dochan [e (a/chan 10)] > (println "Auto-insert" e)) ;; keeps throwing exception saying it cannot > find clojure.core.async > > > Further macroexpansion in cljs-repl confirmed what I was saying with the > resulting code using clojure.core.async. So I came to the conclusion that > since clojurescript relies on clojure for macros, it would use clojure to > load the macros , hence making the reader conditionals work like the > macro's to be used in a clojure file. Another weird thing happened though. > It was auto-inserting clojure.core.async whenever I remove the :clj > require. I am guessing it's cider because whenever I started a different > repl it would behave normally, using a alone rather than cojure.core.asyn > > -- 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.