In my Clojure share, I have the following (which I shamelessly stole):
(defmacro hey-str [name] `(str "hey " ~name)) {:author "Laurent Petit (and others)" :doc "Functions/macros variants of the ones that can be found in clojure.core (note to other contrib members: feel free to add to this lib)"} (defmacro- defnilsafe [docstring non-safe-name nil-safe-name] `(defmacro ~nil-safe-name ~docstring {:arglists '([~'x ~'form] [~'x ~'form ~'& ~'forms])} ([x# form#] `(let [~'i
In my Clojurescript code, I have the following (I: require-macros as c)
(def a nil) (def b []) (def c [{:a 23}]) (js/alert (c/hey-str "Stephen")) ;; should display "hey Stephen" (js/alert (c/-?> a first :a)) ;; should display nil (js/alert (c/-?> b first :a)) ;; should display nil (js/alert (c/-?> c first :a)) ;; should display 23
Unfortunately, when I compile, I get:
WARNING: Use of undeclared Var webstack.client/-?> at line 56 cljs-src/webstack/client.cljs WARNING: Use of undeclared Var webstack.client/-?> at line 57 cljs-src/webstack/client.cljs WARNING: Use of undeclared Var webstack.client/-?> at line 58 cljs-src/webstack/client.cljs
When I open javascript in the browser, I get a “hey Stephen” warning dialog box, but the widespread error “Not releasing TypeError: Unable to call the method“ from undefined ”occurs immediately after clicking“ ok ”on the warning“ hey Stephen. ”Of course, looking at generated javascript code, my js / alert became:
alert([cljs.core.str("hey "), cljs.core.str("Stephen")].join("")); alert(webstack.client.__QMARK__GT_.call(null, webstack.client.__QMARK__GT_.call(null, webstack.client.a, cljs.core.first), "\ufdd0'a")); alert(webstack.client.__QMARK__GT_.call(null, webstack.client.__QMARK__GT_.call(null, webstack.client.b, cljs.core.first), "\ufdd0'a")); alert(webstack.client.__QMARK__GT_.call(null, webstack.client.__QMARK__GT_.call(null, webstack.client.c, cljs.core.first), "\ufdd0'a"))
It's so clear that I can use macros, but something about how macros are written -? > (and related), causes them not to compile. What do I need to do to use macros -?> .?. and `-? →?