3 ms·
Well, there is defonce [http://clojure.github.com/clojure/branch-master/clojure.core-api.html#clojure.core/defonce http://clojure.github.com/clojure/branch-mast
by simonb 14y ago
Well, there is defonce [http://clojure.github.com/clojure/branch-master/clojure.core-api.html#clojure.core/defonce http://clojure.github.com/clojure/branch-master/clojure.core...]
As for function lookup, I recommend reading this thread: http://news.ycombinator.com/item?id=2928285 http://news.ycombinator.com/item?id=2928285
Also, vars are by default static (but can be made dynamic with ^:dynamic).
- Mitt 14y ago`defonce` unfortunately doesn’t help. Without restarting the JVM I can overwrite that var. And that is okay, because defonce is just a protection mechanism, to not delete data when a namespace is repeatedly reloaded. This reloading occurs 99% at development time. Useful tool. But I would like to have real constants. A final class with a static final field (and potentially type information), or something like that. This would give the optimal lookup time, as the JVM would have the direct address. When I (defonce x 1) I can still (def x 2), without restarting the JVM. I want this to not be possible with a defconstant.