1
votes

I'm new to ClojureScript in general and I'm getting a warning with a macro that I don't understand.

I am trying to change a global binding with a macro and when I compile I get a warning that the global variable isn't declared as dynamic even though it is.

So in my macros file I have:

(ns gaz.rendertarget)

(defmacro with-rt [rt & body]
`(binding [*current-rt* ~rt]
    ~@body))

And in the file rendertarget.cljs I have

(ns gaz.rendertarget)

(def ^{:dynamic true} *current-rt* nil)

And on my first compile I get

WARNING:  not declared ^:dynamic at line 173 src/cloj/core.cljs

I am using ClojureScript version 0.0-2138

It all seems to work fine but I don't like warnings. And if I have to have them I'd rather I understood what they were all about :D

1
Hi Gary, i have a question: what does '=' mean in this expression (binding [*current-rt* ~rt]= ~@body) - tangrammer
Ha! It means I accidentally pressed = before copypasting :D - Gary Liddon
Hi @GaryLiddon, have you checked my solution?, i think now it can solve your problem - tangrammer

1 Answers

2
votes

UPDATE:
and have you tried to change the cljs file (and thus namespace too)?

File: blog/utils/rtay.cljs

(ns blog.utils.rtay
  (:require [blog.utils.macros :as macros]))


(def ^:dynamic *current-rt* nil)
(macros/with-rt hola (println "ey"))