开发者

Where can I specify warn-on-reflection in a clj file?

I am trying to use warn-on-reflection in a clj file. When I write:

(set! warn-on-reflection true)

: after the ns declaration I get the error:

 java.lang.Exception: Unable to resolve symbol: warn-on-reflection in this context 

Does an开发者_JS百科yone know why?


Global variables are conventionally named with names that start and end with asterisk.

(set! *warn-on-reflection* true)

I guess you copied that from a forum which makes such text bold.


Update: add these lines in your leiningen project.clj:

  ;; Emit warnings on all reflection calls.
  :global-vars {*warn-on-reflection* true}

https://github.com/technomancy/leiningen/blob/master/sample.project.clj


The (set! *warn-on-reflection* true) is probably the way to go. If you do want to use lein-specific methods to do this, here is some updated info for 2.x:

To set the global in the project definition:

(defproject foo ...
  :global-vars {*warn-on-reflection* true}
  ...)

Or just periodically run lein check, as it will warn on reflection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜