since moving up to 1.3.0alphaxx I've seen lots of compile time warnings 
telling me, as I understand it, that I am dynamically resetting the root 
binding of a var ?

e.g.

Var *session-manager-name* not marked :dynamic true, setting to :dynamic. 
You should fix this before next release!

I've let these go for a while, but was determined to nail them today :

I don't want to add ^dynamic to their definitions, because my intention is 
that they are immutable/const, but I do want to get rid of the warnings.

I figured that somehow, I was resetting them.

So, I look for *session-manager-name* in my code:

[jules@megalodon dada-core]$ find . -name "*.clj" | xargs grep 
session-manager-name
./src/main/clojure/org/dada/core.clj:(def *session-manager-name* 
"SessionManager")
[jules@megalodon dada-core]$ 

So, in the module that I am compiling, there is only one mention and that is 
in the original def.

Then I think that perhaps use-ing or require-ing this module into others 
multiple times (i.e. by pulling in two modules that each pull in the one in 
which the definition resides) may be causing the problem (although I'd be 
very surprised if the runtime did not guard against this happening). So, I 
start thinking about surrounding each def with a check to see if it is 
already bound. Then I start thinking about doing this in a macro. Then I 
figure that it must have already been done. Then I find defonce.

So, I change my const defs to defonces and recompile :

no joy :

Var *session-manager-name* not marked :dynamic true, setting to :dynamic. 
You should fix this before next release!

[jules@megalodon dada-core]$ find . -name "*.clj" | xargs grep 
session-manager-name
./src/main/clojure/org/dada/core.clj:(defonce *session-manager-name* 
"SessionManager")
[jules@megalodon dada-core]$ 

I must be missing something somewhere ?

If the intention of def was to define vars with mutable root bindings then I 
would not need to explicitly declare that intent. So its intention must be 
that root bindings are immutable by default - as mine are. defonce must be 
there to enforce this. So why am I getting all these warnings ?

I must be being dumb, because no-one else seems to have asked this question 
- so, please be gentle :-)

Jules




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

Reply via email to