As mentioned, 'identical?' tests that two objects are physically the same 
in memory. `=` tests that two things are logically equal.

Specifically, all numbers in Clojure are "boxed" as objects like 
java.lang.Long and java.lang.Double. For small integers like 4, the JVM 
will optimize them to make all instances the same object. Hence,

(identical? 4 4)  ;=> true

Larger integers will be instantiated as new objects each time they are 
used, so,

(identical? 128 128)  ;=> true

Some more examples:

;; Keywords are interned:
(identical? :foo :foo)  ;=> true
;; Symbols are not:
(identical? 'foo 'foo)  ;=> false

-S


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