On Saturday, October 25, 2014 2:46:20 PM UTC-7, Marcus Lewis wrote:
> So... I've been using Clojure wrong, because I primarily use ClojureScript.
> 
> Clojure
> my.clj.ns=> (def foo 1)
> #'my.clj.ns/foo
> my.clj.ns=> (set! foo 2)
> IllegalStateException Can't change/establish root binding of: foo with set  
> clojure.lang.Var.set (Var.java:221)
> 
>  ClojureScript
> my.cljs.ns=> (def foo 1)
> 1
> my.cljs.ns=> (set! foo 2)
> 2
> 
> 
> I'm somewhat of a beginner, and I've always been confused by the need for 
> vars *and* atoms. Now it's clear -- I've been misusing vars, via def and set!.
> 
> 
> Thoughts? Sorry if I'm overlooking old mail threads on this topic.
> 
> 
> Could the compiler throw an error when you try to set! a var that's in a cljs 
> namespace?

The best the ClojureScript analyzer could do in this case would be to issue a 
warning, however, I suspect this would add a fair bit overhead since it would 
require checking every call to set!.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to