These days, I was trying to utilize function hash in clojure/clojurescript to 
generate unique id, but it turns out this function has very strange behaviour 
to empty vector parsed from read-string in cljs with in clj.

In clojure, hash function return -2017569654 for empty vector and the one 
parsed from read-string

user=> (hash [])
-2017569654
user=> (hash (read-string "[]"))
-2017569654

However, in cljs, (hash []) returns surprisingly 0. And [] are also equal to 
(read-string "[]").

cljs.user=> (hash (cljs.reader/read-string "[]"))
-2017569654

cljs.user=> (hash [])
0

cljs.user=> (= [] (cljs.reader/read-string "[]"))
true

Does any one know the reason of it and how to solve it in cljs?

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