2013/3/25 Jim foo.bar <jimpil1...@gmail.com>

> if I declare a Integer/String object as private & final within a class, is
> there a way to mutate it?


Strings are immutable but they are backed by arrays. You can create a
native extension that will
mess with that array. Does this count as "true immutability" to you? It
certainly works out just
fine for the majority of Java code and developers out there. In contrast,
Ruby strings are mutable
and it routinely causes annoying issues even without concurrency.

Numerical types are immutable but there are subtle moments, too: writes to
longs and doubles are not
guaranteed to be atomic [1], so there is a special class in the
java.util.concurrent.atomic package [2].

Not sure how strings and numerical types fit into this discussion about
collection mutability.

1. http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.7
2.
http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/AtomicLong.html
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
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/groups/opt_out.


Reply via email to