I think I recall something in a CS class about how String is (or possibly is) implemented. Consider the following:
1) Each character of the alphabet, number, symbol etc. is assigned a memory location. 0x00, 0x01, 0x02, etc. etc. 2) A String has an internal representation as a char[]. So, String s = "test" is really a char[] = ['t', 'e', 's', 't'] To represent this in memory, the char[] is really [0x20, 0x05, 0x19, 0x20] to represent each letter respectively. Now conside a new String s2 = "test". Again, this will have the same "path" of internal memory addresses. Therefore (identical? "test" "test") is the same path of memory addresses and is identical?. On Feb 16, 3:33 am, "C. Arel" <java10c...@gmail.com> wrote: > Thank you all, > It has to be the same object otherwise it makes no sense. Anyways that > is good news since this means that Clojure has a little support built > in so you don't create unneccessary objects. > > /Can Arel > > On 16 Feb, 00:27, Stuart Sierra <the.stuart.sie...@gmail.com> wrote: > > > > > > > > > Since about 1.1, I think, the Clojure compiler calls String.intern() on > > String literals. So yes, they are the same object. > > > -Stuart Sierra -- 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