Gary Liddon
Gary Liddon

Reputation: 379

ClojureScript macro warning about binding to a dynamic variable

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

Upvotes: 1

Views: 408

Answers (1)

tangrammer
tangrammer

Reputation: 3061

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"))

Upvotes: 2

Related Questions