why does Clojure need to cache keywords?

2012-07-18 Thread jaime
Hello, When I read the source code keyword, say, Keyword.java (V1.3), I found that when we intern a keyword, (if I understand it correctly) it uses a cache for keywords: = public static Keyword intern(Symbol sym) { if (sym.meta() != null) sym =

Re: why does Clojure need to cache keywords?

2012-07-18 Thread dennis zhuang
Compare keywords can be very fast. 在 2012-7-18 PM4:51,jaime xiejianm...@gmail.com写道: Hello, When I read the source code keyword, say, Keyword.java (V1.3), I found that when we intern a keyword, (if I understand it correctly) it uses a cache for keywords:

Re: why does Clojure need to cache keywords?

2012-07-18 Thread jaime
I doubt because keyword will use its internal Symbol object to compare with each other (or other objects), it means it's Symbol's interned strings(ns name) make the comparison fast but not this caching stuff. I found a find() method in source code but not sure if the cache is relevant to this

Re: why does Clojure need to cache keywords?

2012-07-18 Thread dennis zhuang
I think this cache is just the same with String.intern method in java,it just want to reduce the cost (memory cpu) of producing keywords frequently especial when using them with map structure. 2012/7/18 jaime xiejianm...@gmail.com I doubt because keyword will use its internal Symbol object to

Re: why does Clojure need to cache keywords?

2012-07-18 Thread jaime
make senseI just came up with this similar answer on my way home...Thanks. 在 2012年7月18日星期三UTC+8下午6时56分42秒,dennis写道: I think this cache is just the same with String.intern method in java,it just want to reduce the cost (memory cpu) of producing keywords frequently especial when using