Camilo Roca <car...@gmail.com> writes:

Hi Camilo,

> Everything is ok with that. The next one on the other hand is what
> puzzles me:
> (identical? \f (first (str "f" "oo")))
> ;;=> true
>
> If what I guess is right, the amount of chars that exist are finite,
> thus Clojure treats them like a "pool of charts". The question is then
> why are not strings implemented as vectors of charts instead of using
> the underlying Java String class?

That wouldn't be better.  Two vectors containing the identical chars in
the same order are still different vectors.

  (map identical? [\f \o \o] [\f \o \o])
  ;=> (true true true)

  (identical? [\f \o \o] [\f \o \o])
  ;=> false

So that's actually exactly the same as with strings.  And as Alex
already explained, strings are more light-weight than vectors, and they
are already highly optimized, e.g., every equal literal string in your
code will usually be represented by the very same string in memory.

Bye,
Tassilo

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to